mercredi 25 janvier 2017

show paginate according to data in relation table in laravel

im going to create blog in laravel now i get post form category in blog and i can only show paginate according to post but i wants to show paginate only for post has relation with category id

i have some problem in my code,please help me to fix my problem.

in controller

//this code show posts according to category id
$postCatId = $request->postCatId;
$postList =PostCat::with("posts")->where('id',$postCatId)->get();

//this code show paginate according to posts has relation with category
$paginate=PostCat::with("posts")->where('id',$postCatId)->paginate(2);

and then return $postList and $paginate to view

in View:

//show posts has relation with category id
@foreach($PostList as $post)
     @foreach($post->posts as $post_item)
     
     @endforeach
@endforeach


//show paginate according to posts has relation with category id


but i cannot show paginate with posts has relation with category id

please help me,thanks



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

Aucun commentaire:

Enregistrer un commentaire