Donations Appreciated

You have not lived today until you have done something for someone who can never repay you. - John Bunyan

EloquentController.php - MySQL RowNum demo

Rank Id Name Email Created At Updated At


    public function getRowNum()
        return view('datatables.eloquent.rownum');

    public function getRowNumData(Request $request)
        DB::statement(DB::raw('set @rownum=0'));
        $users = User::select([
            DB::raw('@rownum  := @rownum  + 1 AS rownum'),
        $datatables = Datatables::of($users);

        if ($keyword = $request->get('search')['value']) {
            $datatables->filterColumn('rownum', 'whereRaw', '@rownum  + 1 like ?', ["%{$keyword}%"]);

        return $datatables->make(true);


        processing: true,
        serverSide: true,
        ajax: '',
        columns: [
            // or just disable search since it's not really searchable. just add searchable:false
            {data: 'rownum', name: 'rownum'},
            {data: 'id', name: 'id'},
            {data: 'name', name: 'name'},
            {data: 'email', name: 'email'},
            {data: 'created_at', name: 'created_at'},
            {data: 'updated_at', name: 'updated_at'}