문제

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!

도움이 되었습니까?

해결책

Does the user model have an hasMany('favorites')? Its required to navigate from a user to his favorites.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top