イムは、私のコントローラにPOST
データにしようが、私はLaravel 5.1は、コントローラにデータを投稿しようとしているが、
MethodNotAllowedHttpException in RouteCollection.php line 219:
エラーメッセージが出ていMethodNotAllowedHttpExceptionエラーをgeting、ここに私のファイルがあります。
私のルートファイル
<?php
Route::get('/', function() {
return view('welcome');
});
// Authentication routes
Route::get('auth/login', 'Auth\[email protected]');
Route::post('auth/login', 'Auth\[email protected]');
Route::get('auth/logout', 'Auth\[email protected]');
// Registration routes
Route::get('register', 'Auth\[email protected]');
Route::post('auth/register', 'Auth\[email protected]');
Route::controllers(['password' => 'Auth\PasswordController',]);
Route::get('/home', '[email protected]');
// Using A Route Closure
Route::get('profile', ['middleware' => 'auth', function() {
// Only authenticated users may enter...
Route::auth();
}]);
// practicing using forms for sending data to the DB & populating form fields with DB data
Route::get('profile', '[email protected]');
Route::post('profile/update', '[email protected]');
profile.blade.php
<form method="POST" action="/profile/update/">
<div class="form-group hidden">
<input type="hidden" name="id" value="<?php echo $users[0]->id;?>">
<input type="hidden" name="_token" value="{{ csrf_token() }}">
<input name="_method" type="hidden" value="PATCH">
</div>
<div class="form-group">
<label for="email"><b>Name:</b></label>
<input type="text" name="name" placeholder="Please enter your email here" class="form-control"/>
</div>
<div class="form-group">
<label for="email"><b>Email:</b></label>
<input type="text" name="email" placeholder="Please enter your email here" class="form-control"/>
</div>
<div class="form-group">
<button type="submit" class="btn btn-default"> Submit </button>
</div>
</form>
&私ProfileController.php
<?php
namespace App\Http\Controllers;
use Auth;
use App\User;
use Illuminate\Http\Request;
use App\Http\Requests;
use App\Http\Controllers\Controller;
class ProfileController extends Controller
{
/**
* Update user profile & make backend push to DB
**/
public function index()
{
if(Auth::check()) {
// connecting to the DB and accessing
$users = User::all();
//var_dump($users);
return view('profile', compact('users'));
}
return view('auth/login');
}
public function updateProfile(Requests $request) {
return $request->all();
}
}
問題が何であるかわかりません。すべてのヘルプみんなのおかげで
@MarcoAurélioDeleuは私の質問を更新しました –
@MarcoAurélioDeleu私は 'POST 'に' PATCH'を追加する必要があると読んでみようとしましたか? –
@MarcoAurélioDeleuiveは私のルートを 'route :: patch'に更新しましたが、同じエラー –