0
votes

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', 'SeedController@store')->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.

1
Try this <form method="POST" action="{{ route('admin.seed',['organization'=>organization_id]) }}">shubham singh

1 Answers

1
votes

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) }}">