Missing argument 2 in Laravel Controller -
i trying log user in , take them page displays content based on slug.
i error :
errorexception in applicantlogincontroller.php line 21: missing argument 2 app\http\controllers\auth\applicantlogincontroller::login() this controller :
public function login(request $request, $slug){ //validate form $this->validate($request, [ 'email' => 'required', 'password' => 'required', 'agree' => 'required' ]); //attempt log 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')); } this route page taking them after login :
route::get('client/index/{slug}', ['as' => 'client.index', 'uses' => 'clientregistrationcontroller@index']); this login routes :
route::get('client/login', 'auth\applicantlogincontroller@showloginform')->name('client.login'); route::post('/client/login', 'auth\applicantlogincontroller@login')->name('client.login.submit'); any ideas on how can solve problem?
this button takes user page content based on slug
<a href="{{ url('client/index/'.$house->slug) }}" class="btn btn-success btn btn-block">book now</a> if user not logged in page redirects login page:
<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=""> have read , accepted <a href="" data-toggle="modal" data-target="#mymodal" class="checkbox-terms-client">terms , 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 password? </a> </div> </div> </form>
you should have $slug declared in post route:
route::post('/client/login/{slug}', 'auth\applicantlogincontroller@login')->name('client.login.submit'); and change form add parameter:
<form class="form-horizontal" role="form" method="post" action="{{ route('client.login.submit', ['slug' => $slug]) }}">
Comments
Post a Comment