Make projects depend on templates

This commit is contained in:
2026-05-25 01:41:27 +00:00
parent 58d2edcacd
commit 5e6426067a
19 changed files with 281 additions and 14 deletions
+13 -1
View File
@@ -7,8 +7,9 @@ use Illuminate\Database\Eloquent\Attributes\Fillable;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Builder;
#[Fillable(['source_project_id', 'name', 'slug', 'copy_areas', 'configuration_snapshot'])]
#[Fillable(['project_id', 'source_project_id', 'name', 'slug', 'is_published', 'copy_areas', 'configuration_snapshot'])]
class ProjectTemplate extends Model
{
/** @use HasFactory<ProjectTemplateFactory> */
@@ -19,9 +20,20 @@ class ProjectTemplate extends Model
return [
'copy_areas' => 'array',
'configuration_snapshot' => 'array',
'is_published' => 'boolean',
];
}
public function scopePublished(Builder $query): Builder
{
return $query->where('is_published', true);
}
public function project(): BelongsTo
{
return $this->belongsTo(Project::class);
}
public function sourceProject(): BelongsTo
{
return $this->belongsTo(Project::class, 'source_project_id');