pagination - Laravel 4 many to many relation paginate -
stuck second , solution did not find answers, maybe searching wrong
my model
class mediacategory extends eloquent { protected $table = "md_categories"; public function media() { return $this->belongstomany('media', 'media_categories')->orderby('id', 'desc'); } }
controller
public function getcategory($slug) { $categories = $this->category->has('media')->orderby('name', 'asc')->get(); $medias = $this->category->whereslug($slug)->get(); // $medias = $results->media(); $this->layout->title = 'média tár'; $this->layout->content = view::make('front::page/results') ->with('categories', $categories) ->with('medias', $medias); }
view
<div class="content-left"> @include('front::partials/search', array('categories' => $categories)) @foreach($medias $data) @foreach($data->media $media) <div class="gallery-thumbs"> <a class="view-more-image" href="{{ url::to('media/details/'.$media->id) }}">kép kiválasztása</a> <a href="{{ url::to($media->mediaoriginal()) }}" rel="prettyphoto" title="{{ $media->title }}"> {{ html::image($media->mediasmall()) }} </a> </div> @endforeach @endforeach </div>
so when change $medias = $this->category->whereslug($slug)->get();
$medias = $this->category->whereslug($slug)->paginate(2ö);
found sultions find()
method
could please give me hint?
okay, result of not sleeping enough makes ask stupid questions , results poor coding
works fine, instead
$medias = $this->category->whereslug($slug)->get();
needed
$data = $this->category->whereslug($slug)->first(); $medias = $data->media()->paginate(30);
Comments
Post a Comment