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...
});
}
}