NotificationService.php 930 B

1234567891011121314151617181920212223242526272829303132
  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. $ids = [];
  22. foreach ($users as $user){
  23. $ids[] = $user->id;
  24. Notification::send($user,new RoutineNotification($info->toArray()));
  25. }
  26. $info->users()->sync($ids);
  27. }
  28. }