44 lines
1.1 KiB
PHP
44 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use App\Models\Concerns\SyncsProjectTemplateOwnership;
|
|
use Database\Factories\TicketTypeFactory;
|
|
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\Relations\HasMany;
|
|
|
|
#[Fillable(['name', 'position', 'project_id', 'project_template_id', 'is_parent'])]
|
|
class TicketType extends Model
|
|
{
|
|
/** @use HasFactory<TicketTypeFactory> */
|
|
use HasFactory;
|
|
use SyncsProjectTemplateOwnership;
|
|
|
|
protected static function booted(): void
|
|
{
|
|
static::saving(function (self $ticketType): void {
|
|
$ticketType->syncProjectTemplateOwnership();
|
|
});
|
|
}
|
|
|
|
protected function casts(): array
|
|
{
|
|
return [
|
|
'is_parent' => 'boolean',
|
|
];
|
|
}
|
|
|
|
public function project(): BelongsTo
|
|
{
|
|
return $this->belongsTo(Project::class);
|
|
}
|
|
|
|
public function tickets(): HasMany
|
|
{
|
|
return $this->hasMany(Ticket::class);
|
|
}
|
|
}
|