I as using DataTables in Laravel 5.1 and I want to increment a variable in a function but this is the error.
Undefined variable: index
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(); }