Open sidebar
<?php namespace App\Services\Assignment; use App\Models\Assignment; use App\Models\Role; use App\Notifications\Assignment\ParticipantAssigned; use Illuminate\Support\Facades\Notification; class ParticipantsNotificationsSender { private Assignment $assignment; private array $participants; public function execute(Assignment $assignment, array $participants) { $this->assignment = $assignment; $this->participants = $participants; $this->notifyParticipants(); $this->notifyAccountants(); } private function notifyParticipants(): void { foreach ($this->participants as $participant) { $participant->user->notify( new ParticipantAssigned($this->assignment, $participant->role) ); } } private function notifyAccountants(): void { $accountants = Role::whereIn('name', ['Accounting Manager', 'Accounting Officer'])->get()->pluck('users')->flatten(); Notification::send( $accountants, new \App\Notifications\Assignment\Accounting\ParticipantAssigned($this->assignment, $this->participants) ); } }
Close sidebar
Back
Please note that all pasted data is publicly available.
X (fomerly Twitter)
GitHub
Use setting
Back
Please note that all pasted data is publicly available.
X (fomerly Twitter)
GitHub
Use setting