Does the user model have an hasMany('favorites')
? Its required to navigate from a user to his favorites.
Laravel 4.1 / Call to undefined method Illuminate\Database\Query\Builder::favorites()
-
29-09-2022 - |
Question
I just have a quick question. A few weeks ago I build a small app where users were able to like a post just for training. This was stored in a favorites table.
Today I wanted to implement that into an application but it does not work anymore.
I am getting this error:
Call to undefined method Illuminate\Database\Query\Builder::favorites()
I dont understand this error because I have simply copied the code from the working project. This is my route.
Route::post('favorites', ['as' => 'favorites.store', function()
{
Auth::user()->favorites()->attach(Input::get('post-id'));
return Redirect::back();
}]);
Can somebody help? Does this have anything to do with Laravel 4.1??? Would be much appreciated.
Thanks!
Solution
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow