Donations Appreciated

No one has ever become poor by giving. - Anne Frank, diary of Anne Frank

Click here to lend your support to: Laravel Datatables and make a donation at pledgie.com !

CollectionController.php - Carbon Demo

Id Name Email Created At Updated At

CollectionController.php

    public function getCarbon()
    {
        return view('datatables.collection.carbon');
    }

    public function getCarbonData()
    {
        $users = User::select(['id', 'name', 'email', 'created_at', 'updated_at'])->get();

        return Datatables::of($users)
            ->editColumn('created_at', '{!! $created_at !!}')
            ->editColumn('updated_at', function ($user) {
                return $user->updated_at->format('Y/m/d');
            })
            ->make(true);
    }

Javascript

    $('#users-table').DataTable({
        processing: true,
        serverSide: true,
        ajax: 'https://datatables.yajrabox.com/collection/carbon-data',
        columns: [
            {data: 'id', name: 'id'},
            {data: 'name', name: 'name'},
            {data: 'email', name: 'email'},
            {data: 'created_at', name: 'created_at'},
            {data: 'updated_at', name: 'updated_at'}
        ]
    });