'array', 'meta' => 'array' ]; public function source() { return $this->belongsTo(Source::class); } public function topics() { return $this->belongsToMany(Topic::class)->withTimestamps(); } public function category() { return $this->belongsTo(Category::class); } public function ScopeRecentArticles() { return $this->with('source', 'topics') ->latest("published_date"); } public function toSearchableArray() { return [ 'id' => $this->id, 'title' => $this->title, 'body' => implode(" ",$this->body), 'author' => $this->author, 'source' => $this->source()->get(), 'topics' => $this->topics()->get() ]; } }