有人可以帮助我如何使用链接到第二个表的student_id登录。例如;第二个表的id为'abc',所以我想以'abc'登录,当它发布到下一页时,它将检索链接到'abc'数据的数据而不是所有数据。登录第二个表格的数据
AuthController.php
public function getLogin()
{
return view('auth.login');
}
public function postLogin(Request $request)
{
if($this->auth->attempt($request->only('student_id', 'password')))
{
return redirect('/student/profile');
}
return redirect('/auth/login')
->withErrors([
'student_id'=>'Invalid User ID'
]);
}
route.php
Route::get('/', function() {
return View::make('auth/login');
});
Route::get('student/profile',
['middleware' => 'auth','uses' =>'Auth\[email protected]']);
Route::post('/student/profile',array(
'as'=>'login',
'uses'=>'[email protected]'
));
login.blade.php
<section id="container">
{!! Form::open(array('action' => 'Auth\[email protected]')) !!}
{!! csrf_field() !!}
<p>Student ID : {!! Form::text('student_id',null)!!}</p>
<p>Password : {!! Form::password('password')!!}</p>
<p>{!! Form::submit('Login') !!} </p>
{!! Form::close()!!}
</section>
你能否详细说明你的问题多一点 –
当我登录的ID:ABC,PWORD:ABC。它将移动到名为profile的下一页。在配置文件表中,有许多数据具有不同的id。所以,我只想要链接到ID:abc的数据。当我登录为'尝试'时,我只想检索数据配置文件,在表格配置文件中有'尝试'..这里有两个表名为用户(用于登录)和配置文件(用于显示数据)。 –
用户成功登录后,您可以使用'Auth :: user();'获取用户详细信息,以便您可以使用它来检索登录用户的'id',然后使用此'id'检索配置文件信息'with'。 –