|
|
|
@ -13,7 +13,6 @@ 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']; |
|
|
|
@ -21,10 +20,9 @@ class BroadcastController extends Controller
|
|
|
|
|
$data['send_to_id'] = implode(", ", $idArray); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
// dd($data); |
|
|
|
|
$result = Broadcast::create($data); |
|
|
|
|
if($result){ |
|
|
|
|
$this->sendNotification($data); |
|
|
|
|
$data['status_send'] !== "registered" ? $this->sendNotification($data) : ''; |
|
|
|
|
return response()->json(['status'=>'success','message'=>'add broadcast successfully!','code'=>200], 200); |
|
|
|
|
}else{ |
|
|
|
|
return response()->json(['status'=>'failed','message'=>'add broadcast failed!','code'=>400], 400); |
|
|
|
@ -54,6 +52,14 @@ class BroadcastController extends Controller
|
|
|
|
|
|
|
|
|
|
$data = Broadcast::find($id); |
|
|
|
|
|
|
|
|
|
$status_send = $request->status_send; |
|
|
|
|
|
|
|
|
|
if($status_send === 'resend' || $status_send === 'send' && !empty($data)) |
|
|
|
|
{ |
|
|
|
|
$data['status_send'] = $status_send; |
|
|
|
|
$this->sendNotification($data); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if($data){ |
|
|
|
|
$result = $data->update($request->all()); |
|
|
|
|
}else{ |
|
|
|
|