Browse Source

Merge branch 'staging' into dev-wahyun

pull/3/head
ibnu 1 year ago
parent
commit
607514d72e
  1. 13
      app/Http/Controllers/BroadcastController.php

13
app/Http/Controllers/BroadcastController.php

@ -15,6 +15,12 @@ class BroadcastController extends Controller
$data = $request->all(); $data = $request->all();
$data['status_send'] = true; $data['status_send'] = true;
$data['created_by'] = $this->currentName; $data['created_by'] = $this->currentName;
if (isset($data['send_to_id'])) {
$idArray = $data['send_to_id'];
if (is_array($data['send_to_id'])) {
$data['send_to_id'] = implode(", ", $idArray);
}
}
// dd($data); // dd($data);
$result = Broadcast::create($data); $result = Broadcast::create($data);
if($result){ if($result){
@ -140,8 +146,10 @@ class BroadcastController extends Controller
} }
break; break;
case 'user': case 'users':
$user = User::where("id", $data['send_to_id'])->whereNotNull('fcm_token')->first(); $idArray = explode(", ", $data['send_to_id']);
foreach ($idArray as $key => $value) {
$user = User::where("id", $value)->whereNotNull('fcm_token')->first();
if (isset($user)) { if (isset($user)) {
FCMService::send( FCMService::send(
$user->fcm_token, $user->fcm_token,
@ -151,6 +159,7 @@ class BroadcastController extends Controller
] ]
); );
} }
}
break; break;
default: default:

Loading…
Cancel
Save