i am trying to return back to departments after add a new department but this what happens :
Route [admin.departments.index] not defined
this is my store function in the DepartmentController
class DepartmentController extends BaseController
{
public function store(Request $request)
{
$this->validate($request, [
'department_name' => 'required|max:191',
]);
$params = $request->except('_token');
$department = $this->departmentRepository->createDepartment($params);
if (!$department) {
return $this->responseRedirectBack('Error occurred while creating department.', 'error', true, true);
}
return $this->responseRedirect('admin.deparments.index', 'Department added successfully' ,'success',false, false);
}
}
this is the responseRedirect function in the base controller
class BaseController extends Controller
{
protected function responseRedirect($route, $message, $type = 'info',
$error = false, $withOldInputWhenError = false)
{
$this->setFlashMessage($message, $type);
$this->showFlashMessages();
if ($error && $withOldInputWhenError) {
return redirect()->back()->withInput();
}
return redirect()->route($route);
}
}
these are the routes
Route::group(['prefix' => 'departments'], function() {
Route::get('/', 'Admin\DepartmentController@index')->name('admin.departments.index');
Route::get('/create', 'Admin\DepartmentController@create')->name('admin.departments.create');
Route::post('/store', 'Admin\DepartmentController@store')->name('admin.departments.store');
Route::get('/{id}/edit', 'Admin\DepartmentController@edit')->name('admin.departments.edit');
Route::post('/update', 'Admin\DepartmentController@update')->name('admin.departments.update');
Route::get('/{id}/delete', 'Admin\DepartmentController@delete')->name('admin.departments.delete');
});
InvalidArgumentException
Route [admin.deparments.index] not defined.