prakash pokhrel
prakash pokhrel

Reputation: 485

MethodNotAllowedHttpException in RouteCollection.php line 251:

AT login.blade.php

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="description" content="Creative - Bootstrap 3 Responsive Admin Template">
    <meta name="author" content="GeeksLabs">
    <meta name="keyword" content="Creative, Dashboard, Admin, Template, Theme, Bootstrap, Responsive, Retina, Minimal">
    <link rel="shortcut icon" href="img/favicon.png">

    <title>welcome</title>
    <link href="css/bootstrap.min.css" rel="stylesheet">
    <link href="css/bootstrap-theme.css" rel="stylesheet">
    <link href="css/elegant-icons-style.css" rel="stylesheet" />
    <link href="css/font-awesome.css" rel="stylesheet" />
    <link href="css/style.css" rel="stylesheet">
    <link href="css/style-responsive.css" rel="stylesheet" />

</head>
  <body class="login-img3-body">
    <div class="container">
      <form class="login-form" method="post" action="{{ url('/dashboard') }}"> //{{ route('login') }}
      <input type="hidden" name="_token" value="{{ csrf_field() }} ">   

        <div class="login-wrap">
            <p class="login-img"><i class="icon_lock_alt"></i></p>
            <div class="input-group">
              <span class="input-group-addon"><i class="icon_profile"></i></span>
              <input type="text" name="Username" class="form-control" placeholder="Username" autofocus>
            </div>
            <div class="input-group">
                <span class="input-group-addon"><i class="icon_key_alt"></i></span>
                <input type="password" name="password" class="form-control" placeholder="Password">
            </div>
            <label class="checkbox">
                <input type="checkbox" value="remember-me"> Remember me
                <span class="pull-right"> <a href="#"> Forgot Password?</a></span>
            </label>
            <button class="btn btn-primary btn-lg btn-block" type="submit">Login</button>
            <button class="btn btn-info btn-lg btn-block" type="submit">Signup</button>
        </div>
      </form>
    <div class="text-right">
            <div class="credits">

                <a href="https://facebook.com/t.prakash.pokhrel/"> Developer::xxx</a> 
            </div>
        </div>
    </div>
  </body>
</html>

And web.php

Route::get('/' , ['as' => '/' , 'uses'=> 'loginController@getlogin']);
    Route::post('/login', ['as' => 'login', 'uses'=> 'loginController@postlogin']);


    Route::group(['middleware' =>['authen']], function () 
    {
    Route::get('/dashboard',['as'=>'dashboard', 'uses'=> 'dashboardController@dashboard']);
    Route::get('/logout' ,['as'=>'logout', 'uses'=> 'loginController@getLogout']);

});

i am newer on laravel . i have this error happen . how to solve and method="post" action="{{ url('/dashboard') }}"> //{{ route('login') }} "{{ csrf_field() }} .In here on action field which url should pass .. i mean destination or same path .. i want to redirect to dashboard .. thank you :)

Upvotes: 0

Views: 1475

Answers (2)

V.joshi
V.joshi

Reputation: 39

Try to change route

First you need to set login route url in form (action="{{ url('/login') }}") and after submit form in postlogin function use auth and check email password is correct or not.if correct than redirect url is dashboard.

Upvotes: 2

GAURAV ROZATKAR
GAURAV ROZATKAR

Reputation: 1

check what ur route is expecting by using

php artisan route:list command in terminal next change your form method to that

if you want user to redirect to dashboard u need to do it in ur controller`

`class ProfileController extends Controller
 { 
     //your code here

 public dashbord(){

 // your code 

  return view("your dashboard view path");      
  }

Upvotes: 0

Related Questions