feat Log Masuk & Keluar Sistem
This commit is contained in:
@@ -13,6 +13,7 @@ use Illuminate\Support\Facades\Http;
|
|||||||
|
|
||||||
use App\Dashboard;
|
use App\Dashboard;
|
||||||
use App\User;
|
use App\User;
|
||||||
|
use Carbon\Carbon;
|
||||||
|
|
||||||
class LoginController extends Controller
|
class LoginController extends Controller
|
||||||
{
|
{
|
||||||
@@ -62,6 +63,7 @@ class LoginController extends Controller
|
|||||||
$credentials = $request->only('email', 'password');
|
$credentials = $request->only('email', 'password');
|
||||||
|
|
||||||
if (Auth::guard('web')->attempt($credentials)) {
|
if (Auth::guard('web')->attempt($credentials)) {
|
||||||
|
|
||||||
$auth_user = Auth::guard('web')->user();
|
$auth_user = Auth::guard('web')->user();
|
||||||
$api_url = config('api.url');
|
$api_url = config('api.url');
|
||||||
if($auth_user['roles'] == 'teller'){
|
if($auth_user['roles'] == 'teller'){
|
||||||
@@ -147,8 +149,23 @@ class LoginController extends Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function logout(){
|
public function logout(){
|
||||||
|
$current = Carbon::now();
|
||||||
|
$current = new Carbon();
|
||||||
|
$current = $current->toDateString();
|
||||||
|
$auth_user = Auth::guard('web')->user();
|
||||||
Auth::logout();
|
Auth::logout();
|
||||||
Session::flush();
|
Session::flush();
|
||||||
|
$session = Http::withOptions(['verify' => config('app.api_verify')])->post(config('api.url') . '/api/logoutsession/' . $auth_user['cawangan'], [
|
||||||
|
'id' => $auth_user['id'],
|
||||||
|
'nama' => $auth_user['name'],
|
||||||
|
'nokp' => $auth_user['no_kp'],
|
||||||
|
'email' => $auth_user['email'],
|
||||||
|
'taraf' => $auth_user['role_harian'],
|
||||||
|
'tarikh' => $current,
|
||||||
|
|
||||||
|
|
||||||
|
]);
|
||||||
|
|
||||||
return Redirect::to('/');
|
return Redirect::to('/');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -75,10 +75,30 @@ class HomeController extends Controller
|
|||||||
|
|
||||||
$countkhazanah = sizeof($gadai) + sizeof($listserah);
|
$countkhazanah = sizeof($gadai) + sizeof($listserah);
|
||||||
|
|
||||||
|
$session = Http::withOptions(['verify' => config('app.api_verify')])->post(config('api.url') . '/api/logsession/' . $auth_user['cawangan'], [
|
||||||
|
'id' => $auth_user['id'],
|
||||||
|
'nama' => $auth_user['name'],
|
||||||
|
'nokp' => $auth_user['no_kp'],
|
||||||
|
'email' => $auth_user['email'],
|
||||||
|
'taraf' => $auth_user['role_harian'],
|
||||||
|
'tarikh' => $current,
|
||||||
|
|
||||||
|
|
||||||
|
]);
|
||||||
return view('homepage.khazanah.home',compact('cawangan_info','api_url','countkhazanah'));
|
return view('homepage.khazanah.home',compact('cawangan_info','api_url','countkhazanah'));
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
$cawangan_info = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url') . '/api/cawangan/'. $auth_user['cawangan'])->json();
|
$cawangan_info = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url') . '/api/cawangan/'. $auth_user['cawangan'])->json();
|
||||||
|
$session = Http::withOptions(['verify' => config('app.api_verify')])->post(config('api.url') . '/api/logsession/' . $auth_user['cawangan'], [
|
||||||
|
'id' => $auth_user['id'],
|
||||||
|
'nama' => $auth_user['name'],
|
||||||
|
'nokp' => $auth_user['no_kp'],
|
||||||
|
'email' => $auth_user['email'],
|
||||||
|
'taraf' => $auth_user['role_harian'],
|
||||||
|
'tarikh' => $current,
|
||||||
|
|
||||||
|
|
||||||
|
]);
|
||||||
return view('homepage.'.$auth_user['roles'].'.home',compact('cawangan_info','api_url'));
|
return view('homepage.'.$auth_user['roles'].'.home',compact('cawangan_info','api_url'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user