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 { public function execute(Assignment $assignment, array $participants) { $this->notifyParticipants($assignment, $participants); $this->notifyAccountants($assignment, $participants); } private function notifyParticipants(Assignment $assignment, array $participants): void { foreach ($participants as $participant) { $participant->user->notify( new ParticipantAssigned($assignment, $participant->role) ); } } private function notifyAccountants(Assignment $assignment, array $participants) { $accountants = Role::whereIn('name', ['Accounting Manager', 'Accounting Officer'])->get()->pluck('users')->flatten(); Notification::send( $accountants, new \App\Notifications\Assignment\Accounting\ParticipantAssigned($assignment, $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