lasthourcloud/app/Models/Project.php

43 lines
969 B
PHP
Raw Normal View History

<?php
namespace App\Models;
class Project extends BaseModel
{
protected static function booted()
{
static::created(function ($project) {
ProjectSetting::create([
'project_id' => $project->id,
]);
2023-04-25 12:43:35 +00:00
Environment::create([
'name' => 'Production',
'project_id' => $project->id,
]);
});
}
2023-04-25 12:43:35 +00:00
protected $fillable = [
'name',
'description',
'team_id',
'project_id'
];
2023-06-07 13:08:35 +00:00
static public function ownedByCurrentTeam()
{
return Project::whereTeamId(session('currentTeam')->id);
}
2023-04-25 12:43:35 +00:00
public function environments()
{
return $this->hasMany(Environment::class);
}
2023-04-25 12:43:35 +00:00
public function settings()
{
return $this->hasOne(ProjectSetting::class);
}
2023-04-25 12:43:35 +00:00
public function applications()
{
2023-03-30 17:50:27 +00:00
return $this->hasManyThrough(Application::class, Environment::class);
}
}