mercredi 12 juillet 2017

Paginate Results of Model Laravel

i have a problem with pagination in laravel 5.3

The code:

 public function deals()
{
    return $this->belongsToMany('App\Models\ListsDeals', 'list_has_deals' , 'list_id', 'deal_id')->withPivot('list_id');
}


public function form_edit_list( $id ){

    $list = Lists::find( $id );

    PAGINATE THIS -----> $deals = $list->deals;

    $user = User::find( $list->id_user );

    $categoriesArray = ListsCategories::all();

    $featuresArray = ListsFeatures::all();

    $images = ListsGalleries::all();

    return view( "admin.forms.form_edit_list" )
                    ->with( "list", $list )
                    ->withCategoriesArray( $categoriesArray )
                    ->withFeaturesArray( $featuresArray )
                    ->withImages( $images )
                    ->with( "user", $user );                          
    }

I try this

$deals = $list->deals->paginate(5);

How i can paginate the results of deals? because paginate is not a method of that, regards.



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2teo98C
via IFTTT

Aucun commentaire:

Enregistrer un commentaire