/
home
/
old_henza
/
server
/
app
/
Models
/
File Upload :
llllll
Current File: //home/old_henza/server/app/Models/Notification.php
<?php namespace App\DB; use Illuminate\Database\Eloquent\Model; use LaravelFCM\Message\OptionsBuilder; use LaravelFCM\Message\PayloadDataBuilder; use LaravelFCM\Message\PayloadNotificationBuilder; use LaravelFCM\Facades\FCM as FCM; class Notification extends Model { protected $fillable = [ 'type', 'payload', 'owner_id', 'user_id', 'meta', 'sts' ]; protected $casts = [ 'meta' =>"array", ]; public function user() { return $this->belongsTo('App\DB\User'); } public function customer() { return $this->belongsTo('App\DB\Customer','owner_id'); } public static function store($token = null,$title,$body){ $optionBuilder = new OptionsBuilder(); $optionBuilder->setTimeToLive(60*20); $notificationBuilder = new PayloadNotificationBuilder($title); $notificationBuilder->setBody($body); $dataBuilder = new PayloadDataBuilder(); $option = $optionBuilder->build(); $notification = $notificationBuilder->build(); $data = $dataBuilder->build(); // if (is_null($token)){ // $token = auth('customer')->user()->token_mobile; // } $downstreamResponse = FCM::sendTo($token, $option, $notification, $data); $downstreamResponse->numberSuccess(); $downstreamResponse->numberFailure(); $downstreamResponse->numberModification(); $downstreamResponse->tokensToDelete(); $downstreamResponse->tokensToModify(); $downstreamResponse->tokensToRetry(); $downstreamResponse->tokensWithError(); //$customer = Customer::where('token_mobile',$token)->first(); // Notify::create([ // 'payload'=>$title, // 'owner_id'=>$customer->id, // ]); } }
Copyright ©2k19 -
Hexid
|
Tex7ure