itxrahulsingh
3 months ago
612
2
Laravel

Button Action To Controller Route

Posted 3 months ago by itxrahulsingh

sir am using yajra/laravel-datatablesyajra/laravel-datatables and added a column and on this column, I 've added a button and I want to delete the records using the button

 if($request->ajax())
        {
            return DataTables::of(User::query())
 ->addColumn('action', function(User $user){
                    $button = '<button type="button" name="edit" id="'.$user->id.'" class="edit btn btn-primary btn-sm"><i class="fas fa-eye"></i></button>';
                    $button .= '&nbsp;<button type="button" name="edit" id="'.$user->id.'" class="edit btn btn-warning btn-sm"><i class="fas fa-edit"></i></button>';
                    $button .= '&nbsp;<button type="button" name="edit" id="'.$user->id.'" class="delete btn btn-danger btn-sm"><i class="fas fa-trash-alt"></button>';

                    return $button;
                })
                ->rawColumns(['action'])
                ->make(true);
        }
        return view('admin.users.index'
``

Please sign in or create an account to participate in this conversation.