php - Laravel 4 Eloquent paginate related model -


i'm working on laravel project has 2 models: offer belongsto category.

it's easy paginate results when i'm retrieving records:

$offers = offer::paginate(10); 

but when i'm trying retrieve offers has specific category, not work:

$category = category::whereid($category_id)->with('offers')->first()->paginate(10); 

and error:

 undefined property: illuminate\pagination\paginator::$offers  

update:

i've solved replacing second code this:

$category = category::find($category_id); $offers = $category->offers()->paginate(10); 

replace second code this:

$category = category::find($category_id); $offers = $category->offers()->paginate(10); 

Comments

Popular posts from this blog

hibernate - How to load global settings frequently used in application in Java -

python 3.x - Mapping specific letters onto a list of words -

objective c - Ownership modifiers with manual reference counting -