mardi 13 février 2018

L5.6 orderBy() in combination with paginate() returns the same row multiple times

Controller:

public function index($devicetype)
{
    $devices = Device::where('device_type', $devicetype)
    ->orderBy('created_at', 'desc')
    ->paginate(config('myapp.pagination.items_per_page'));
    return view('devices.general.index', compact('devices'));
}

I am getting the same device multiple times on different pages in my blade.php view.

But dd(Device::where('device_type', $devicetype)->orderBy('created_at', 'desc')->get()); gives me a correct collection without multiple entries.

Any ideas/suggestions?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire