I've just made an app in Laravel running on Semantic UI, and when I run the program, it displays a MethodNotAllowedHttpException error. I have the code for the routes as displayed:
<?php
Route::get('/', function () {
return view('welcome');
});
Route::get('/view', [
'uses' => 'ViewController@index',
'as' => 'view'
]);
Route::post('/login', [
'uses' => 'Auth\LoginController@login',
'as' => 'login'
]);
The blade file also includes the 'method' and 'action' functions, as well. ` @extends('layouts.app')
@section('title')
Login
@endsection
@section('content')
@if(count($errors) > 0)
<div class="ui bulleted list">
@foreach($errors as $error)
<div class="item">{{ $error }}</div>
@endforeach
</div>
@endif
<div class="ui middle aligned center aligned grid">
<div class="column">
<h2 class="ui teal header">
<p>
Log in to your account
</p>
</h2>
<form class="ui large form" action="{{ route('login') }}" method="post">
<div class="ui stacked segment">
<div class="field">
<div class="ui left icon input">
<i class="user icon"></i>
<input type="text" id="email" name="email" placeholder="Enter your email">
</div>
<div class="ui left icon input">
<div class="ui left icon input">
<i class="lock"></i>
<input type="password" id="password" name="password" placeholder="Enter your password">
</div>
</div>
</div>
<div class="ui fluid large teal submit button">Login</div>
</div>
</form>
<div class="ui message">
<p>
New to us? <a href="#">Sign up</a>
</p>
</div>
</div>
</div>
@endsection`
In my Auth folder, I also have the following code for the LoginController`
public function login(Request $request)
{
if(Auth::attempt(['email' => $request['email']], ['password' => $request['password']]))
{
return redirect()->route('view');
}
return redirect()->back();
}
My routes list shows that the routes are of post:
+--------+----------+----------+---------------+----------------------------
---------------------------+--------------+
| Domain | Method | URI | Name | Action
| Middleware |
+--------+----------+----------+---------------+----------------------------
---------------------------+--------------+
| | GET|HEAD | / | | Closure
| web |
| | GET|HEAD | api/user | | Closure
| api,auth:api |
| | POST | login | auth.login |
App\Http\Controllers\Auth\LoginController@login | web,guest |
| | POST | register | auth.register |
App\Http\Controllers\Auth\RegisterController@register | web,guest |
| | GET|HEAD | view | view |
App\Http\Controllers\ViewController@index | web |
+--------+----------+----------+---------------+----------------------------
---------------------------+--------------+
Is there something that isn't typed correctly in the code? Can you use functions in the blade templating engine such as 'action' or 'method'?