notify.php 923 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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. }