NotificationService.php 864 B

1234567891011121314151617181920212223242526272829
  1. <?php
  2. namespace App\Services;
  3. use App\Notifications\RoutineNotification;
  4. use App\SeeLog;
  5. use Illuminate\Support\Facades\Notification;
  6. class NotificationService
  7. {
  8. static function SingleRegister(string $message,string $number,string $authorityName)
  9. {
  10. $default = [
  11. "message" => $message,
  12. "title" => "工单提示",
  13. "link" => "order/workOrder/index?client_code={$number}",
  14. "mark" => 0,
  15. "delivered" => '0',
  16. ];
  17. /** @var SeeLog $info */
  18. $info = SeeLog::query()->create($default);
  19. $users = app("AuthorityService")->authorityGetUsers($authorityName);
  20. if ($users->count()==0)return;
  21. Notification::send($users,new RoutineNotification($info->toArray()));
  22. $info->users()->sync(array_column($users->toArray(),"id"));
  23. }
  24. }