0
我正在嘗試登錄一個用戶,並將他們帶到顯示基於一個slu content的內容的頁面。在Laravel控制器中缺少參數2
我得到這個錯誤:
ErrorException in ApplicantLoginController.php line 21:
Missing argument 2 for App\Http\Controllers\Auth\ApplicantLoginController::Login()
這是我的控制器:
public function Login(Request $request, $slug){
//Validate the form
$this->validate($request, [
'email' => 'required',
'password' => 'required',
'agree' => 'required'
]);
//Attempt to log the user in
if (Auth::guard('applicant')->attempt(['email' => $request->email,'password' => $request->password])) {
$house = House::where('slug', '=', $slug)->first();
return view('client.index')->withHouse($house);
}
return redirect()->back()->withInput($request->only('email'));
}
這是該頁面的路線,我登錄後帶他們到:
Route::get('client/index/{slug}', ['as' => 'client.index', 'uses' => '[email protected]']);
這是我的登錄路線:
Route::get('client/login', 'Auth\[email protected]')->name('client.login');
Route::post('/client/login', 'Auth\[email protected]')->name('client.login.submit');
有關如何解決此問題的任何想法?
這是將用戶的頁面與基於塞
<a href="{{ url('client/index/'.$house->slug) }}" class="btn btn-success btn btn-block">Book now</a>
內容。如果用戶沒有在頁面登錄按鈕重定向到該登錄頁面:
<form class="form-horizontal" role="form" method="POST" action="{{ route('client.login.submit') }}">
<input name="_token" type="hidden" value="{{ csrf_token()}}"/>
<div class="form-group">
<label for="email" class="col-md-3 control-label"></label>
<div class="col-md-6">
<input type="email" class="form-control" placeholder="Your Email" name="email" required="">
</div>
</div>
<div class="form-group">
<label for="password" class="col-md-3 control-label"></label>
<div class="col-md-6">
<input type="password" class="form-control" placeholder="Password" name="password" required="">
</div>
</div>
<div class="form-group">
<div class="col-md-6 col-md-offset-3">
<div class="checkbox">
<label>
<input type="checkbox" name="remember"> Remember Me
</label>
</div>
</div>
</div>
<div class="form-group">
<div class="col-md-6 col-md-offset-3">
<div class="checkbox">
<label>
<input type="checkbox" name="agree" required=""> I have read and accepted the <a href="" data-toggle="modal" data-target="#myModal" class="checkbox-terms-client">terms and condition</a>
</label>
</div>
</div>
</div>
<div class="form-group">
<div class="col-md-8 col-md-offset-3">
<input type="submit" value="Login" class="btn btn-primary">
</input>
<a class="btn btn-link" href="#">
Forgot Your Password?
</a>
</div>
</div>
</form>
我已經做到了,我得到這個錯誤:ErrorException在UrlGenerationException.php線17: 缺少所需參數〔路線:client.login.submit] [URI:客戶機/註冊/ {段塞} ]。 – Martin
你可以發表你打電話/客戶/登錄的表單嗎? – Laerte
我已經添加了將用戶帶到基於slug的信息的頁面的按鈕。當我嘗試登錄時,用戶需要登錄才能訪問該頁面,我收到我發佈的錯誤消息。 – Martin