|
|
|
@ -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: |
|
|
|
|