I am using laravel to create simple form:
{{ Form::open(array('route' => 'postrequest')) }}
{{ Form::text('Name') }}
{{ Form::text('Surname') }}
{{ Form::submit('submit') }}
{{ Form::close() }}
In my routes.php file is defined route:
Route::post('postrequest', function()
{
return View::make('home');
});
But I'm getting error in log file:
Next exception 'ErrorException' with message 'Route [postrequest] not defined.
I couldnt find solution on internet. What I'm doing wrong?
All Laravel routes are defined in your route files, which are located in the routes directory. These files are automatically loaded by your application's App\Providers\RouteServiceProvider . The routes/web.php file defines routes that are for your web interface.
You try to use here named route. If you want to do so you need to change your route into:
Route::post('postrequest', array('as' => 'postrequest', function()
{
return View::make('home');
}));
or you can of course change the way you open your form using direct url:
{{ Form::open(array('url' => 'postrequest')) }}
But you should really consider using named routes.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With