Model: App\Models\Article => Relation: ChristianKuri\LaravelFavorite\Models\Favorite - You should add with(ChristianKuri\LaravelFavorite\Models\Favorite) to eager-load this relation.
wire controller
/**
* The read function.
* @return array
*/
public function read(): array
{
return [
'articles' => Article::search($this->search)
->with('user')
->where('status', true)
->latest()
->paginate($this->perPage),
];
}
public function render()
{
return view('livewire.front.article-wire', $this->read())->layout('layouts.app');
}
Detailed description
Hi there!
When i check if article is favorited by auth user
$article->isFavorited()
the debugbar gives me
Model: App\Models\Article => Relation: ChristianKuri\LaravelFavorite\Models\Favorite - You should add with(ChristianKuri\LaravelFavorite\Models\Favorite) to eager-load this relation.
wire controller
In Article model i tried
but it didn't work
How could I eager load that?
Thanks!