Passing a value to controller like my-route/edit/{id} throws an error
Passing a value to controller like my-route/edit/{id} throws an error
My controller is located in /Admin directory inside controllers. I am new to Laravel as well as datatables. My client management page works fine with the below route. It have a datatable.
Route::controller('manage-clients', 'Admin\ManageClientController', ['anyData' => 'manage-clients.data', 'getIndex' => 'manage-clients']);
I will paste my controller below :
class ManageClientController extends Controller
{
public function getIndex()
{
return View('admin.manageclients');
}
public function anyData()
{
$clients = DB::table('users')
->select(['id', 'first_name', 'last_name', 'email', 'created_at', 'updated_at'])
->where('type', '=', '');
return Datatables::of($clients)->addColumn('action', function ($clients) {
return '<a href="manage-clients/edit/'.$clients->id.'" class="btn btn-xs btn-primary"><i class="glyphicon glyphicon-edit"></i> Edit</a>';
})->editColumn('id', 'ID: {{$id}}')->make(true);
}
public function editClient($id)
{
return $id;
}
}
As you can see I have added an 'Edit' button for each record in the datatable. Its url is manage-clients (which is our main route)/edit/{client id}. I have defined route for this edit page to work like below :
Route::get('manage-clients/edit/{id}', ['as'=>'editclient', 'uses'=>'Admin\ManageClientController@editClient']);
When ever I click on the edit button (which means when ever I open an edit page), like manage-clients/edit/4, it throws an "Controller method not found" error. I have gone through several google search results but couldn't find a fix for this. Please help.
Thanks in advance
Answers
I'm afraid I know very little about Laravel - you'd probably have more luck trying on a Laravel specific forum.
Allan