I am unable to pass url in views html form action tag.
if you want to call controller from form action that time used following code:
<form action="{{ action('SchoolController@getSchool') }}" >
Here SchoolController
is a controller name and getSchool
is a method name, you must use get
or post
before method name which should be same as in form tag.
Your form is also missing '{{csrf_field()}}'
You need to set a name to your Routes. Like this:
Route::get('/','WelcomeController@home')->name('welcome.home'); Route::post('/', array('as' => 'log_in', 'uses' => 'WelcomeController@log_in'))->name('welcome.log_in'); Route::get('home', 'HomeController@index')->name('home.index');
I just put name on Routes that need this. In my case, to call from tag form at blade template. Like this:
<form action="{{ route('home.index') }}" >
Or, You can do this:
<form action="/" >
The following should work.
{{ Form::open( array('url' => action('WelcomeController@log_in'), 'files'=>true,'method'=>'post') ) }}
...
{{ Form::close() }}
Laravel 5.8 Step 1: Go to the path routes/api.php add: Route::post('welcome/login', 'WelcomeController@login')->name('welcome.login'); Step2: Go to the path file view
<form method="POST" action="{{ route('welcome.login') }}">
</form>
Result html
<form method="POST" action="http://localhost/api/welcome/login">
<form>
Use action="{{ action('WelcomeController@log_in') }}"
however TokenMismatchException means that you are missing a CSRF token in your form.
You can add this by using <input name="_token" type="hidden" value="{{ csrf_token() }}">