Browse Source

Merge pull request 'fix broadcast' (#177) from dev-wahyu into staging

Reviewed-on: ordo/adw-backend#177
pull/3/head
ibnu 1 year ago
parent
commit
35dc4bd26b
  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['status_send'] = true;
$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);
$result = Broadcast::create($data);
if($result){
@ -140,8 +146,10 @@ class BroadcastController extends Controller
}
break;
case 'user':
$user = User::where("id", $data['send_to_id'])->whereNotNull('fcm_token')->first();
case 'users':
$idArray = explode(", ", $data['send_to_id']);
foreach ($idArray as $key => $value) {
$user = User::where("id", $value)->whereNotNull('fcm_token')->first();
if (isset($user)) {
FCMService::send(
$user->fcm_token,
@ -151,6 +159,7 @@ class BroadcastController extends Controller
]
);
}
}
break;
default:

Loading…
Cancel
Save