I'm trying to Put Some values into session after Successful Login in Laravel for e.g name, img, username, last_login etc. I tried using Auth::user() which fetches every details from users detail when echoed.
How can i immediately put some other parameter from different table when user login successfully
My LoginController.php
<?php
namespace App\Http\Controllers\Auth;
use Illuminate\Http\Request;
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 = '/';
/**
* Create a new controller instance.
*
* @return void
*/
public function __construct()
{
$this->middleware('guest')->except('logout');
}
public function username()
{
return 'username';
}
public function credentials(Request $request)
{
return [
'username' => $request->username,
'password' => $request->password,
];
}
protected function authenticated(Request $request, $user)
{
if ( !$user->activated ) {
auth()->logout();
return back()->withErrors(['email' => 'Your account is not activated yet, please verify your Account.']);
}
return redirect()->intended($this->redirectPath());
}
}