Changeset View
Changeset View
Standalone View
Standalone View
src/app/Console/Development/PushUserCommand.php
- This file was added.
<?php | |||||
namespace App\Console\Development; | |||||
use App\Backends\Events; | |||||
use App\Console\Command; | |||||
class PushUserCommand extends Command | |||||
{ | |||||
/** | |||||
* The name and signature of the console command. | |||||
* | |||||
* @var string | |||||
*/ | |||||
protected $signature = 'push:user {user} {message} {--type=}'; | |||||
/** | |||||
* The console command description. | |||||
* | |||||
* @var string | |||||
*/ | |||||
protected $description = 'Push server-side event (notification) to user mobile device(s).'; | |||||
/** | |||||
* Execute the console command. | |||||
* | |||||
* @return mixed | |||||
*/ | |||||
public function handle() | |||||
{ | |||||
$user = $this->getUser($this->argument('user')); | |||||
if (!$user) { | |||||
$this->error("User not found."); | |||||
return 1; | |||||
} | |||||
$message = $this->argument('message'); | |||||
$type = $this->option('type') ?: 'message'; | |||||
Events::pushMessage($user, $message, $type); | |||||
} | |||||
} |