dimanche 1 novembre 2015

Resource index parameters

I've wrote a controller to have it's index to output the DataTables plugin data.

A excerpt:

public function index() {
    return Datatable::collection(\App\Slip::where('paid', '=', false)->get())
        ...
        ->make();
}

and the route:

Route::resource('api/slip', 'SlipsController');

everything works fine, the problem is that this index return only items with paid = false that's right for one view, but for the other view I need all items/rows.

so what's the best practice to make index function cover both cases (all and those with paid = false)?

A post param is the first thing that comes to my mind, but the data is loaded by the DataTables plugin.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire