dimanche 26 avril 2020

How to use get and paginate same time in Laravel

I would like to use paginate. I researched if I use paginate() I have to erase ->get(). but I got error. Could you teach me how to add paginate please?

my current code

$images = ImageGallery::orderBy(DB::raw('LENGTH(wc), wc'))->get()->paginate(5);
        return view('image-gallery2',compact('images'));

blade file code


UPDATE

if I do this

$images = ImageGallery::orderBy(DB::raw('LENGTH(wc), wc'))->get()->paginate(5);

This error

BadMethodCallException
Method Illuminate\Database\Eloquent\Collection::paginate does not exist. 

If I write below

$images = ImageGallery::orderBy(DB::raw('LENGTH(wc), wc'))->paginate(5);
        return view('image-gallery2',compact('images'));

I got this error

Facade\Ignition\Exceptions\ViewException
Call to undefined method App\ImageGallery::links() (View: //resources/views/image-gallery2.blade.php) 


via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire