我想創建簡單的登入系統,並且我製作了一個登入系統,但它說登入詳細資訊錯誤。我嘗試做轉儲測試回傳 null。請參閱評論中的 dd 測試。由於這個原因也無法註銷
我的登入控制器是:
<?php namespace App\Http\Controllers; use Illuminate\Http\Request; use Illuminate\Support\Facades\Auth; use App\Models\User; use Validator; class LoginController extends Controller { public function index() { return view('login'); } public function store(Request $request) { $this->validate($request, [ 'email' => 'required|email', 'password' => 'required|alphaNum|min:3' ]); $user_data = array( 'email' => $request->get('email'), 'password' => $request->get('password') ); //$user = Auth::user(); //dd($user); I have done dump test but it is returning null if(Auth::attempt($user_data)) { return redirect()->route('welcome'); } else { return back()->with('error','wrong Login Details'); } } }
我的登入刀片是
@if ($message = Session::get('error')) <div class="alert alert-danger alert-block"> <button type="button" class="close" data-dismiss="alert">×</button> <strong>{{ $message }}</strong> </div> @endif @if (count($errors) > 0) <div class="alert alert-danger"> <ul> @foreach($errors->all() as $error) <li>{{ $error }}</li> @endforeach </ul> </div> @萬一