资源索引参数

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.

Why not?. You need detect your specified view and send some extra param in ajax-request. Like:

 $('...').DataTable({
      ....
      "ajax": {
            'type': 'GET',
            'url': "....",
            'data': {paid: false},

      },
      ....
 });

Now in action:

public function index(Request $request) {
  $paid = $request->input('paid');      
  $items = [];
  if ($paid){
    $items = \App\Slip::all()->get();
  }else{
    $items = \App\Slip::where('paid', '=', false)->get();
  }           

  return Datatable::collection($items)
    ...
    ->make();
}