Browse Source

notification data

master
Siti Rahayu 4 years ago
parent
commit
14d5456fb1

+ 26
- 2
app/Http/Controllers/Main/TaskController.php View File

if($request->modul == '02') if($request->modul == '02')
{ {
$compound = Compound::with('ConfidentialFile')->where('non',$request->non)->first(); $compound = Compound::with('ConfidentialFile')->where('non',$request->non)->first();
$faulty = Faulty::with('DeedLaw', 'Department') ->where('_id', $compound->seksyen_kesalahan_n)->first();
$jbkod = $compound->jbkod_n;
} }
else{ else{
$compound = Compound::with('ConfidentialFile')->where('kpd',$request->kpd)->first(); $compound = Compound::with('ConfidentialFile')->where('kpd',$request->kpd)->first();
$faulty = Faulty::with('DeedLaw', 'Department') ->where('_id', $compound->seksyen_kesalahan)->first();
$jbkod = $compound->jbkod;
} }


$file = ConfidentialFile::where('no_siri',$compound->ConfidentialFile->no_siri)->first(); $file = ConfidentialFile::where('no_siri',$compound->ConfidentialFile->no_siri)->first();
$jbkod = $compound->jbkod;

$data = [];
$now = Carbon::now(); $now = Carbon::now();
$gDate = $now->format('F Y'); $gDate = $now->format('F Y');


{ {


$this->dispatch(new StoreCompoundEPBT($request->all(), $compound->kpd, $user->StaffDetail->full_name, $user->StaffDetail->no_badan, $compound->seksyen_kesalahan)); $this->dispatch(new StoreCompoundEPBT($request->all(), $compound->kpd, $user->StaffDetail->full_name, $user->StaffDetail->no_badan, $compound->seksyen_kesalahan));

$data = [
'non' => $compound->non,
'jenis' => $compound->jenis_n
'nama' => $compound->nama,
'identity' => $compound->identity,
'alamat' => $compound->alamat,
'nama_kawasan' =>$compound->nama_kawasan,
'nama_taman' => $compound->nama_taman,
'nama_jalan' =>$compound->nama_jalan,
'catatan' => $compound->catatan,
'latlong' => $compound->latlong,
'jabatan' => $faulty->Department->jnama,
'akta' => $faulty->DeedLaw->nama,
'tempoh' => $compound->tempoh,
'tindakan' => $compound->tindakan ?? "",
'created_n' => $compound->created_n,
];
} }


$reg_id = array(); $reg_id = array();
} }
} }



if(count($reg_id) > 0) { if(count($reg_id) > 0) {
$client = new \GuzzleHttp\Client(); $client = new \GuzzleHttp\Client();
$result = $client->request('POST', url('api/push/notification'), [ $result = $client->request('POST', url('api/push/notification'), [
'form_params' => [ 'form_params' => [
'title' => $roles->name.' '.$compound->kpd, 'title' => $roles->name.' '.$compound->kpd,
'msg' => 'Kompaun ini telah di pindahkan ke modul '.$roles->name, 'msg' => 'Kompaun ini telah di pindahkan ke modul '.$roles->name,
'data' => $data,
'register_id' => $reg_id, 'register_id' => $reg_id,
] ]
]); ]);

+ 4
- 2
app/Http/Controllers/NotificationController.php View File

public function sendNotification(Request $request){ public function sendNotification(Request $request){
$title = $request->title; $title = $request->title;
$msg = $request->msg; $msg = $request->msg;
$data = $request->data;
$register_id = $request->register_id; $register_id = $request->register_id;


if($register_id != null){ if($register_id != null){
$staff = Staff::with('StaffDetail')->where('token_firebase',$register_id[$key])->first(); $staff = Staff::with('StaffDetail')->where('token_firebase',$register_id[$key])->first();
if(!empty($staff)){ if(!empty($staff)){
$dataNoti = [ $dataNoti = [
'title' => $request->title,
'body' => $request->msg,
'title' => $title,
'body' => $msg,
'data' => $data,
]; ];
$staff->notification()->create($dataNoti); $staff->notification()->create($dataNoti);
} }

Loading…
Cancel
Save