Route To Grouped Routes With Prefix Correctly In Laravel
I have a group of routes with a prefix.
In my web routes the routes with an admin prefix go to a separate route file:
Route::group(['namespace' => 'Admin', 'prefix' => 'admin', 'as' => 'admin.', 'middleware' => 'admin'], function () {
includeRouteFiles(__DIR__ . '/Admin/');
});
So I have to add admin
as prefix in my routes. In my Admin
directory I defined the routes as following:
Route::prefix('organization/{organization}')->group(function () {
Route::post('seed', '[email protected]')->name('seed');
});
My problem is routing to the routes inside this group. I used the command php artisan route:list
to see more info about my routes. It says:
- My route name is:
admin.seed
- My URI is:
admin/organization/{organization}/seed
When I link to this route as admin.seed
in my form I get the following error:
Missing required parameters for [Route: admin.seed] [URI: admin/organization/{organization}/seed]. (View: D:\xampp\htdocs\minute-mn-503\resources\views\admin\organizations\show.blade.php)
I tried linking it as:
admin.seed
admin/seed/1
admin/organization/1/seed
admin/organization/1.seed
But none of them seems to work. This is the line of code for example:
<form method="POST" action="{{ route('admin/organization/'.$organization->id.'.seed') }}">
Any idea on how I might route these correctly? I couldn't find any clear explanation in the Laravel docs.
Answer
You must be using this:
<form method="POST" action="{{ url('admin/organization/' . $organization->id .'/seed') }}">
or:
<form method="POST" action="{{ route('admin.seed', $organization->id) }}">
Related Questions
- → "failed to open stream" error when executing "migrate:make"
- → October CMS Plugin Routes.php not registering
- → OctoberCMS Migrate Table
- → OctoberCMS Rain User plugin not working or redirecting
- → October CMS Custom Mail Layout
- → October CMS - How to correctly route
- → October CMS - Conditionally Load a Different Page
- → Make a Laravel collection into angular array (octobercms)
- → In OctoberCMS how do you find the hint path?
- → How to register middlewares in OctoberCMS plugin?
- → Validating fileupload(image Dimensions) in Backend Octobercms
- → OctoberCMS Fileupload completely destroys my backend
- → How do I call the value from another backed page form and use it on a component in OctoberCms