[ 'source' => 'title' ] ]; } public function author() { return $this->hasOne(User::class, 'id', 'author_id'); } public function post_category() { return $this->hasOne(Category::class, 'id', 'category'); } public function scopeSearch($query, $term) { $term = "%$term%"; $query->where(function($query) use ($term) { $query->where('title', 'like', $term); }); } }