dtra49684 2016-03-18 12:39
浏览 37

RouteCollection.php第219行中的MethodNotAllowedHttpException错误laravel:

I get this error when i try to access the post signin route. I'm new to laravel and i can't seem to figure out how to solve this error. Please help.

My Routes.php

 Route::group(['middleware' => ['web']], function () {
 Route::get('/', [
'uses'=>'\ocsaf\Http\Controllers\HomeController@index',
'as'=>'home',
 ]);



/*
  *Authentication
 */

Route::get('/signup', [
 'uses'=>'\ocsaf\Http\Controllers\AuthController@getSignUp',
 'as'=>'auth.signup',
 'middleware' => ['guest'],
 ]);

 Route::post('/signup', [
 'uses'=>'\ocsaf\Http\Controllers\AuthController@postSignUp',
 'middleware' => ['guest'],
 ]);

 Route::get('/signin', [
 'uses'=>'\ocsaf\Http\Controllers\AuthController@getSignIn',
 'as'=>'auth.signin',
 'middleware' => ['guest'],
 ]);

 Route::post('/signup', [
 'uses'=>'\ocsaf\Http\Controllers\AuthController@postSignIn',
 'middleware' => ['guest'],
 ]);

  Route::get('/signout', [
 'uses'=>'\ocsaf\Http\Controllers\AuthController@getSignOut',
 'as'=>'auth.signout',
  ]);


 /*
 *search
 */

  Route::get('/search', [
  'uses'=>'\ocsaf\Http\Controllers\SearchController@getResults',
  'as'=>'search.results',
  ]);



  /*
  *Profile
  */

   Route::get('/user/{username}', [
   'uses'=>'\ocsaf\Http\Controllers\ProfileController@getProfile',
   'as'=>'profile.index',
   ]);

   Route::get('/profile/edit', [
   'uses'=>'\ocsaf\Http\Controllers\ProfileController@getEdit',
   'as'=>'profile.edit',
   'middleware'=>['auth'],
   ]);

   Route::post('/profile/edit', [
   'uses'=>'\ocsaf\Http\Controllers\ProfileController@postEdit',
   'as'=>'profile.edit',
   'middleware'=>['auth'],
   ]);

   Route::post('/profile/edit', [
   'uses'=>'\ocsaf\Http\Controllers\StatusController@postStatus',
   'as'=>'status.post',
   'middleware'=>['auth'],
   ]);

   });

AuthController.php

    namespace ocsaf\Http\Controllers;
    use Auth;
   use Illuminate\Http\Request;
   use ocsaf\Models\User;



  class AuthController extends Controller
  {

  public function getSignUp()
  {
  return view('auth.signup');
  }

public function postSignUp(Request $request)
{
$this->validate($request, [
'email' => 'required|unique:users|email|max:255',
'username' => 'required|unique:users|alpha_dash|max:255',
'password' => 'required|min:6',


 ]);
 User::create([
    'email' => $request-> input('email'),
    'username' => $request-> input('username'),
    'password' => bcrypt($request -> input('password')),
 ]);

  return redirect()
  ->route('home')
  ->with('info', 'You have signed up, Please sign in!');
   }

  public function getSignIn()
  {
  return view('auth.signin');
  }

  public function postSignIn(Request $request)
  {
  $this->validate($request, [
  'email' => 'required',
  'password' => 'required',

  ]);

  if(!Auth::attempt($request -> only(['email', 'password' ]), 
  $request ->         has('remember'))){
    return redirect() ->back()->
 with('info', 'could not sign you in with those   details   ');
 }

 return redirect() ->route('home')->with('info', 'You are now signed in');

 }

 }

my signin.blade.php form statement

    <form class="form-vertical" role = "form" 
    method = "post" action = "{{     route('auth.signin'); }}">
  • 写回答

1条回答 默认 最新

  • doushi9856 2016-03-18 12:41
    关注

    Your form method is post but for the route auth.signin the HTTP verb is get.

    评论

报告相同问题?

悬赏问题

  • ¥20 测距传感器数据手册i2c
  • ¥15 RPA正常跑,cmd输入cookies跑不出来
  • ¥15 求帮我调试一下freefem代码
  • ¥15 matlab代码解决,怎么运行
  • ¥15 R语言Rstudio突然无法启动
  • ¥15 关于#matlab#的问题:提取2个图像的变量作为另外一个图像像元的移动量,计算新的位置创建新的图像并提取第二个图像的变量到新的图像
  • ¥15 改算法,照着压缩包里边,参考其他代码封装的格式 写到main函数里
  • ¥15 用windows做服务的同志有吗
  • ¥60 求一个简单的网页(标签-安全|关键词-上传)
  • ¥35 lstm时间序列共享单车预测,loss值优化,参数优化算法