HEX
Server: Microsoft-IIS/8.5
System: Windows NT YDAWBH120 6.3 build 9600 (Windows Server 2012 R2 Standard Edition) AMD64
User: tentjecom_web (0)
PHP: 7.4.14
Disabled: NONE
Upload Files
File: D:/HostingSpaces/SBogers10/hours.komma.pro/app/Komma/Projects/Project.php
<?php

namespace App\Komma\Projects;

use App\Komma\ActivityLog\Activity;
use App\Komma\Companies\Company;
use App\Komma\Notifications\Notification;
use App\Komma\ProjectWorkers\ProjectWorker;
use App\Komma\Settings\ProjectTemplates\ProjectTemplate;
use App\Komma\Subprojects\Subproject;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Notifications\Notifiable;

class Project extends Model
{
    use SoftDeletes, Notifiable;

    protected $dates = ['deleted_at'];

    /**
     * @return \Illuminate\Database\Eloquent\Relations\HasMany
     */
    public function Subprojects()
    {
        return $this->hasMany(Subproject::class);
    }

    /**
     * @return \Illuminate\Database\Eloquent\Relations\HasMany
     */
    public function ProjectWorkers()
    {
        return $this->hasMany(ProjectWorker::class);
    }

    public function hasAllowedUsersRestriction()
    {
        return $this->excluded_users !== null;
    }

    public function allowedUsers()
    {
        return explode(',', $this->excluded_users);
    }

    /**
     * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
     */
    public function Company()
    {
        return $this->belongsTo(Company::class);
    }

    /**
     * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
     */
    public function ProjectTemplate()
    {
        return $this->belongsTo(ProjectTemplate::class);
    }

    /**
     * @return \Illuminate\Database\Eloquent\Relations\MorphMany
     */
    public function Notifications()
    {
        return $this->morphMany(Notification::class, 'notification');
    }

    /**
     * @return \Illuminate\Database\Eloquent\Relations\MorphMany
     */
    public function Activities()
    {
        return $this->morphMany(Activity::class, 'subject');
    }


    // this is a recommended way to declare event handlers
    protected static function boot() {
        parent::boot();

        static::deleting(function($project) { // before delete() method call this
            $project->ProjectWorkers()->delete();
            // do the rest of the cleanup...
        });
    }
}