dimanche 28 octobre 2018

How can I put "paginate" method in my controller index function?

I am going to put paginate method to view my data in my controller index function. I have been configured all things with paginate and but I am unable to guess where should I put following paginate in the index function,

paginate(10);

my index function,

public function index()
    {

        $vehicles = Vehicle::with('uploads')->get()->sort(function ($a, $b) {
        if ($a->adtype !== $b->adtype) {
            return $b->adtype - $a->adtype;
        }

        return $a->adtype
            ? ($a->updated_at->gt($b->updated_at) ? -1 : 1)
            : ($a->created_at->gt($b->created_at) ? -1 : 1);
    });

    return view('vehicles.index')->withVehicles($vehicles);
    }

where should I put them?



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

Aucun commentaire:

Enregistrer un commentaire