Routes

Closed
Vanguard - Advanced PHP Login and User Management Vanguard - Advanced PHP Login and User Management July 04, 2018
Login to reply
Milos Stojanovic Support Agent
5 years ago

Hey Joshua,

Not sure but you probably did something wrong. I've just tried the code and it is working as it should.

What I did is :

1) Created the following test routes in routes/web.php file:

Route::get('companies', function () {
    return view('test');
});
Route::post('companies', function () {
    return 'post route handled';
})->name('companies.store');

Those routes use closures but it should work the same when you use controllers.

2) Added the test.blade.php file to resources/views folder with the following content

{{ Form::open(['route' => 'companies.store']) }}
<input type="text" placeholder="name" name="test">
<button type="submit">Go!</button>
{{ Form::close() }}

The route form is being rendered properly and can be submitted without any issues.

But anyways, this is Laravel thing and has nothing to do with the Vanguard itself.

- Milos

Joshua Blevins
5 years ago

Why when I write a route like this

Route::post('companies','CompaniesController@store')->name('companies.store');


Then try try to call it on a form like this

{{ Form::open(['route' => 'companies.store']) }}

I get asset  to found

however I can call it this way

{{ Form::open(['action' => 'Vanguard\Http\Controllers\Web\CompaniesController@store']) }}

you can see my route, controller, and blade files here.

https://laracasts.com/discuss/channels/laravel/action-companiescontroller-at-store-not-defined