1
我在larave 5.1使用數據表,我想在功能上使用的增量變化,但這個錯誤是:如何在laravel控制器中使用變量?
未定義的變量:指數
public function create()
{
$index = 0;
return Datatables::of(news::select('news.id as check','news.id as number','news.title','news.body','news.hits','news.created_at'))
->editColumn('check',function($row){ return '<input type="checkbox" name="checkedBox1[]" value="'.$row->check.'">'; })
->editColumn('number',function($row){ return ++$index; })
->editColumn('created_at',function($row){ return jDate::forge(strtotime($row->created_at))->format('datetime'); })
->make();
}