|
|
@@ -17,6 +17,8 @@ use Mail; |
|
|
|
use App\Model\Staff; |
|
|
|
use App\Model\StaffDetail; |
|
|
|
use App\Model\Module\Department; |
|
|
|
use App\Model\Module\DeedLaw; |
|
|
|
use App\Model\Module\Faulty; |
|
|
|
use App\Model\User; |
|
|
|
use App\Model\UserDetail; |
|
|
|
use App\Model\Module\Compound; |
|
|
@@ -35,7 +37,7 @@ class LoginController extends BaseController |
|
|
|
|
|
|
|
public function requestStaffLogin(Request $request) { |
|
|
|
|
|
|
|
$user = ''; $data = array(); |
|
|
|
$user = ''; $data = array(); |
|
|
|
|
|
|
|
$rememberMe = false; |
|
|
|
$user = Staff::with(['StaffDetail' => function($q){ |
|
|
@@ -67,21 +69,46 @@ class LoginController extends BaseController |
|
|
|
$user->token_firebase = ''; |
|
|
|
$user->save(); |
|
|
|
|
|
|
|
$staff = StaffDetail::with('Department')->where('_id', $user->_id)->first(); |
|
|
|
if(!empty($staff->Department)){ |
|
|
|
foreach ($staff->Department as $key => $d) { |
|
|
|
$tempJ[] = $d->_id; |
|
|
|
//get all staff's related department names & ids |
|
|
|
$staff = StaffDetail::with('Department')->where('_id', $user->_id)->first(); |
|
|
|
$jabatan = array(); |
|
|
|
if(!empty($staff->Department)) |
|
|
|
{ |
|
|
|
|
|
|
|
foreach ($staff->Department as $key => $d) |
|
|
|
{ |
|
|
|
array_push($jabatan , array( |
|
|
|
'jbnama' => $d->jnama, |
|
|
|
'jbkod' => $d->_id, |
|
|
|
)); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
$jabatan = implode( ", ", $tempJ ); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
//get all notice sections & deedlaws |
|
|
|
$notis = array(); |
|
|
|
$sec_faulty = Faulty::with('DeedLaw', 'Department')->whereIn('itkod', ['33', '9', '8', '10'])->get(); |
|
|
|
if(!empty($sec_faulty)) |
|
|
|
{ |
|
|
|
foreach ($sec_faulty as $sf) |
|
|
|
{ |
|
|
|
array_push($notis, array( |
|
|
|
'k_id' => $sf->_id, |
|
|
|
'k_nama' => '['.$sf->sketr.'] '.$sf->nama, |
|
|
|
'a_id' => $sf->DeedLaw->_id, |
|
|
|
'a_nama' => $sf->DeedLaw->nama, |
|
|
|
)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
array_push($data, array( |
|
|
|
'User' => $user->StaffDetail, |
|
|
|
'token' => $user->api_token, |
|
|
|
'jawatan' => $user->StaffDetail->gred, |
|
|
|
'token_firebase' => $user->token_firebase, |
|
|
|
'jbkod' => $jabatan |
|
|
|
'jabatan' => $jabatan, |
|
|
|
'notis' => $notis, |
|
|
|
)); |
|
|
|
|
|
|
|
return $this->sendResponse($data, 'Berjaya log masuk'); |