avatar
DatatablesController.php

arif05rachman 88 9th Apr, 2019

                                           
                         <?php

namespace App\Http\Controllers;
use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Routing\Controller as BaseController;
use Illuminate\Foundation\Validation\ValidatesRequests;
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
use Yajra\Datatables\Datatables;
use DB;
use Session;
use Validaor;
use Auth;
use App\User;
use App\Http\Controllers\Controller;
use Illuminate\Foundation\Auth\VerifiesEmails;


class DatatablesController extends Controller
{
    public function __construct()
    {
    //    $this->middleware('auth:user');
    }
    
    public function index()
    {
        $counts = DB::table('users')->count();
        return view('datatables.index')->with(['counts'=> $counts]);
    }
    
    /**
 * Displays datatables front end view
 *
 * @return \Illuminate\View\View
 */
    public function getIndex()
    {
        return view('datatables.index');
    }

/**
 * Process datatables ajax request.
 *
 * @return \Illuminate\Http\JsonResponse
 */
    public function anyData()
    {
        $get_data = DB::table('users')
            ->select(
                [
                    'id',
                    'name',
                    'email',
                    'create_at',
                    'update_at'
                ]
                );
        return Datatables::of($get_data)
        ->addColumn('action', function($r_data) {
            $delete_route = route('user_delete');
            return '<button>NOTICE</button>';
        })
        ->rawColumn(['action'])
        ->make(true);
        //return Datatables::collection(User::all())->make(true);
    }
}
                      
                                       
To share this paste please copy this url and send to your friends
RAW Paste Data
Recent Pastes