Ad

How To Set Route For Edit In Yajra Datatables

- 1 answer

I am fetching data in yajra DT and add the column for edit and delete but don't understand how to set route and get the id from url to edit that specific employee.

public function fullEmp(){
    $data=employees::select('*')->orderBy('employee_id','DESC');

    return Datatables::of($data)->addColumn('action', function ($data) {
        return '<a target="_blank" rel="nofollow noreferrer" href="'.action('[email protected]', ['user' => $data->id]).'" class="btn btn-primary btn-sm mb-1">
        <i class="fa fa-pencil" aria-hidden="true"></i>
    </a>';
    })->make(true);
}

this code showing that this url is not defined. i am confuse that how to define it

Ad

Answer

Looking at the code you posted you can try something like that in your routes/web.php file:

Route::get('/employees/{user}/edit', '[email protected]');
Ad
source: stackoverflow.com
Ad