notify.php 920 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <?php
  2. namespace App\Console\Commands;
  3. use App\Models\Server;
  4. use App\Models\User;
  5. use App\Notifications\ServerCreationError;
  6. use Illuminate\Console\Command;
  7. class notify extends Command
  8. {
  9. /**
  10. * The name and signature of the console command.
  11. *
  12. * @var string
  13. */
  14. protected $signature = 'notify:user {id}';
  15. /**
  16. * The console command description.
  17. *
  18. * @var string
  19. */
  20. protected $description = 'Send test notifications to this user';
  21. /**
  22. * Create a new command instance.
  23. *
  24. * @return void
  25. */
  26. public function __construct()
  27. {
  28. parent::__construct();
  29. }
  30. /**
  31. * Execute the console command.
  32. *
  33. * @param int $id
  34. * @return int
  35. */
  36. public function handle()
  37. {
  38. User::findOrFail($this->argument('id'))->notify(new ServerCreationError(Server::all()[0]));
  39. return 'message send';
  40. }
  41. }