ChristianKuri / laravel-favorite

Allows Laravel Eloquent models to implement a 'favorite', 'like', 'remember' and 'follow' features.
MIT License
226 stars 48 forks source link

Auth::user()->favorite(Model::class) can be only called in a controller or in routes.php #31

Closed mdbtekny closed 2 years ago

mdbtekny commented 2 years ago

Detailed description

I was trying to get the favorite items of a user when I noticed that no results are shown if the query is performed from blade or livewire. How can we call the method favorite() globally?

Context

Use this method in Blade or with Laravel Livewire

Possible implementation

Could be used like as a Helper function(?)

Your environment

Include as many relevant details about the environment you experienced the bug in and how to reproduce it.