How can i submit form using name route when i am logged in with admin guard?

91 Views Asked by At

im using multiple authentication using guards and i stuck with routing of resource Controller

I have two Different Controllers with same name in different namespaces

Route::namespace('Admin')->prefix('admin')->group(function(){
    Route::resource('test','HomeController');
});

Route::namespace('Vendor')->prefix('vendor')->group(function(){
    Route::resource('test','HomeController');
});

Now i have form for admin

<form action="{{ route('test.store') }}" method="post">
    @csrf
    <input type="text" name="name">
    <input type="submit"/>
</form>

When i submit this form it redirect to the controller of vendor store.

Q. How can i submit form to the HomeController of admin namespace using **name route when i am logged in with admin guard?**

1

There are 1 best solutions below

0
On

i got the solution we can differentiate both controller by using 'as' with resource route like

Route::resource('test', 'HomeController',['as' => 'admin']);

after that i can use route name like route(admin.test.index) and so on

got the refrence from Laravel named route for resource controller