Frage

Stuck for a second and for my solution did not find any answers, maybe i was 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 as $data)
        @foreach($data->media as $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 i change $medias = $this->category->whereSlug($slug)->get(); to $medias = $this->category->whereSlug($slug)->paginate(2ö); i only found sultions to the find() method

Could please someone give me a hint?

War es hilfreich?

Lösung

Okay, the result of not sleeping enough makes you ask stupid questions and results poor coding

Works fine, instead

$medias = $this->category->whereSlug($slug)->get();

Needed

$data = $this->category->whereSlug($slug)->first();

$medias = $data->media()->paginate(30);
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top