%PDF- %GIF98; %PNG; .
Cyber Programmer
Logo of a company Server : Apache
System : Linux host.digitalbabaji.in 4.18.0-513.11.1.el8_9.x86_64 #1 SMP Wed Jan 17 02:00:40 EST 2024 x86_64
User : addictionfreeind ( 1003)
PHP Version : 7.2.34
Disable Function : exec,passthru,shell_exec,system
Directory :  /home/addictionfreeind/www/admin1/app/Listeners/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /home/addictionfreeind/www/admin1/app/Listeners/NewProjectListener.php
<?php

namespace App\Listeners;

use App\Models\User;
use App\Scopes\ActiveScope;
use App\Events\NewProjectEvent;
use App\Notifications\NewProject;
use App\Notifications\NewProjectMember;
use App\Notifications\NewProjectStatus;
use App\Notifications\ProjectMemberMention;
use Illuminate\Support\Facades\Notification;

class NewProjectListener
{

    /**
     * @param NewProjectEvent $event
     */

    public function handle(NewProjectEvent $event)
    {
        if ($event->project->client_id != null) {
            $clientId = $event->project->client_id;
            // Notify client
            $notifyUsers = User::withoutGlobalScope(ActiveScope::class)->findOrFail($clientId);

            if (!is_null($notifyUsers) && $event->projectStatus == 'NewProjectClient') {

                Notification::send($notifyUsers, new NewProject($event->project));
            }
        }

        $projectMembers = $event->project->projectMembers;

        if ($event->projectStatus == 'statusChange') {
            if (!is_null($event->notifyUser) && !($event->notifyUser instanceof \Illuminate\Database\Eloquent\Collection)) {
                $event->notifyUser->notify(new NewProjectStatus($event->project));
            }

            Notification::send($projectMembers, new NewProjectStatus($event->project));
        }

        if ($event->notificationName == 'NewProject') {

            Notification::send($event->notifyUser, new NewProjectMember($event->project));

        } elseif ($event->notificationName == 'ProjectMention') {

            Notification::send($event->notifyUser, new ProjectMemberMention($event->project));

        }

    }

}

VaKeR 2022