2017-02-15 3 views
0

Hallo alle hoffen, Sie können mir helfen.Multi Auth Laravel 5.4 - "Route [Admin-Login] nicht definiert"

Ich habe versucht, eine Multi-Auth-App mit der neuen Version von Laravel 5.4, wo ich ein Benutzerformular für die Anmeldung und Anmeldung, und ein weiteres Formular für die Admin-Benutzer haben.

Nach dem ersten Controller für meine Admin-Anmeldeseite Erstellen der Fehler auf dem Titel kommen von auf die Route gehen: http://localhost:8000/admin_login

Dies sind meine Routen aus der Konsole erstellt: php Handwerker Route: Liste

Route::get('/', function() { 
    return view('welcome'); 
}); 

Auth::routes(); 

Route::get('admin_login', 'AdminAuth\[email protected]'); 
Route::post('admin_login', 'AdminAuth\[email protected]'); 
Route::post('admin_logout', 'AdminAuth\[email protected]'); 
Route::post('admin_password/email', 'AdminAuth\[email protected]'); 
Route::get('admin_password/reset', 'AdminAuth\[email protected]'); 
Route::post('admin_password/reset', 'AdminAuth\[email protected]'); 
Route::get('admin_password/reset/{token}', 'AdminAuth\[email protected]'); 
Route::get('admin_register', 'AdminAuth\[email protected]'); 
Route::post('admin_register', 'AdminAuth\[email protected]'); 


Route::get('/home', '[email protected]'); 
Route::get('/admin_home', '[email protected]'); 

Das ist mein LoginController von AdminAuth:

<?php 

namespace App\Http\Controllers\AdminAuth; 

use App\Http\Controllers\Controller; 
use Illuminate\Foundation\Auth\AuthenticatesUsers; 

class LoginController extends Controller 
{ 
    /* 
    |-------------------------------------------------------------------------- 
    | Login Controller 
    |-------------------------------------------------------------------------- 
    | 
    | This controller handles authenticating users for the application and 
    | redirecting them to your home screen. The controller uses a trait 
    | to conveniently provide its functionality to your applications. 
    | 
    */ 

    use AuthenticatesUsers; 

    /** 
    * Where to redirect users after login. 
    * 
    * @var string 
    */ 
    protected $redirectTo = '/home'; 

    /** 
    * Create a new controller instance. 
    * 
    * @return void 
    */ 
    public function __construct() 
    { 
     $this->middleware('guest', ['except' => 'logout']); 
    } 

    public function showLoginForm() 
    { 
     return view('admin-auth.login'); 
    } 
} 

Und das ist die Anmeldungs ​​Ansicht von Admin:

@extends('layouts.app') 

@section('content') 
<div class="container"> 
    <div class="row"> 
     <div class="col-md-8 col-md-offset-2"> 
      <div class="panel panel-default"> 
       <div class="panel-heading">Login Admin</div> 
       <div class="panel-body"> 
        <form class="form-horizontal" role="form" method="POST" action="{{ route('admin_login') }}"> 
         {{ csrf_field() }} 

         <div class="form-group{{ $errors->has('email') ? ' has-error' : '' }}"> 
          <label for="email" class="col-md-4 control-label">E-Mail Address</label> 

          <div class="col-md-6"> 
           <input id="email" type="email" class="form-control" name="email" value="{{ old('email') }}" required autofocus> 

           @if ($errors->has('email')) 
            <span class="help-block"> 
             <strong>{{ $errors->first('email') }}</strong> 
            </span> 
           @endif 
          </div> 
         </div> 

         <div class="form-group{{ $errors->has('password') ? ' has-error' : '' }}"> 
          <label for="password" class="col-md-4 control-label">Password</label> 

          <div class="col-md-6"> 
           <input id="password" type="password" class="form-control" name="password" required> 

           @if ($errors->has('password')) 
            <span class="help-block"> 
             <strong>{{ $errors->first('password') }}</strong> 
            </span> 
           @endif 
          </div> 
         </div> 

         <div class="form-group"> 
          <div class="col-md-6 col-md-offset-4"> 
           <div class="checkbox"> 
            <label> 
             <input type="checkbox" name="remember" {{ old('remember') ? 'checked' : '' }}> Remember Me 
            </label> 
           </div> 
          </div> 
         </div> 

         <div class="form-group"> 
          <div class="col-md-8 col-md-offset-4"> 
           <button type="submit" class="btn btn-primary"> 
            Login 
           </button> 

           <a class="btn btn-link" href="{{ route('admin_password.request') }}"> 
            Forgot Your Password? 
           </a> 
          </div> 
         </div> 
        </form> 
       </div> 
      </div> 
     </div> 
    </div> 
</div> 
@endsection 

Vielen Dank für Ihre Hilfe!

Antwort

1

Eigentlich haben Sie eine Route ohne Namen definiert. Also Login Ansicht von Admin ersetzen

action="{{ route('admin_login') }}" 

mit

action="{{ url('admin_login') }}" 

Das Gleiche gilt für andere Routen.

ich auch Multi-Auth Aufgabe war die Lösung, denken so können Sie sogar Routen wie folgt hinzu:

Route::group(['prefix' => 'admin'], function() { 
    Auth::routes();  
}); 

hoffe, das hilft!