Reputation: 618
I have This admin routes:
Route::group([
'namespace' => 'Auth',
], function () {
// Authentication Routes...
Route::get('login', 'LoginController@showLoginForm')->name('login_page');
Route::post('login', 'LoginController@login')->name('login');
Route::post('logout', 'LoginController@logout')->name('logout');
});
Route::group([
'middleware' => [
'auth:admin',
],
], function () {
// for all admins
Route::get('/', 'AdminController@index')->name('dashboard');
Route::get('home', 'AdminController@index')->name('dashboard');
Route::get('dashboard', 'AdminController@index')->name('dashboard');
// for administrator
// users
Route::group(['prefix' => 'users', 'as' => 'users.',], function () {
Route::get('all', 'UserController@index')->name('index');
Route::get('ajax', 'UserController@ajax')->name('ajax');
Route::get('create', 'UserController@create')->name('create');
Route::post('post', 'UserController@store')->name('store');
Route::get('show/{id}', 'UserController@show'); // ->where('id', '[0-9]+');
Route::post('change_status', 'UserController@change_status')->name('change_status');
Route::post('delete', 'UserController@delete')->name('delete');
});
});
I need to action form in create.blade
for store data:
<form method="POST" action="{{ route('users.store') }}">
but in action I see this error:
> "Route [users.store] not defined. (View: C:\xampp\htdocs\laravel-multiauth\resources\views\admin\pages\users\create.blade.php)"
name of router not defined in users group route. How do can i fix?
Upvotes: 1
Views: 2872
Reputation: 618
I found problem.I need to add admin before .users.store
like this:
{{ route('admin.users.store') }}
Upvotes: 0
Reputation: 14559
Try this:
Route::prefix('users')->name('users.')->group(function() {
...
});
Upvotes: 1
Reputation: 2059
I don't see any problem. The fastest answer is to run php artisan route:list
and see if your route exists there
If it exists and there is no problem what so ever then run
php artisan route:clear
and if it didn't work then I have to see the whole web.php
file
Upvotes: 0