ldc-supportweb/app/Models/GitlabMilestone.php
2026-06-05 17:05:46 +02:00

101 lines
2.9 KiB
PHP

<?php
declare(strict_types=1);
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Uwil\LaravelActivityLogs\Traits\HasActivityLog;
use Uwil\LaravelI18n\Helpers\TranslationHelper;
use Uwil\LaravelI18n\Interfaces\TranslatableModel;
use Uwil\LaravelI18n\Traits\Models\HasTranslations;
/**
* @property int $id Primary key of the gitlab milestone.
* @property string $title Title of the gitlab milestone.
* @property string $url Url of the gitlab milestone.
* @property string $is_closed Closed status of the gitlab milestone.
* @property string $gitlab_id Gitlab id of the gitlab milestone.
* @property string $gitlab_iid Gitlab iid of the gitlab milestone.
* @property string $gitlab_project_id Gitlab project id of the gitlab milestone.
* @property string $g_created_at Created at date of the gitlab milestone.
* @property string $g_updated_at Updated at date of the gitlab milestone.
* @property string $g_closed_at Closed at date of the gitlab milestone.
* @property string $g_due_date Due at date of the gitlab milestone.
* @property-read \Illuminate\Support\Carbon $created_at Date the gitlab milestone was created.
* @property-read \Illuminate\Support\Carbon $updated_at Date the gitlab milestone was updated.
* @property-read \Illuminate\Support\Carbon $deleted_at Date the gitlab milestone was deleted.
*/
class GitlabMilestone extends Model implements TranslatableModel
{
use HasActivityLog;
/** @use \Illuminate\Database\Eloquent\Factories\HasFactory<\Database\Factories\GitlabMilestoneFactory> */
use HasFactory;
use HasTranslations;
/**
* The attributes that are mass assignable.
*
* @var list<string>
*/
#[\Override]
protected $fillable = [
'title',
'url',
'is_closed',
'gitlab_id',
'gitlab_iid',
'gitlab_project_id',
'g_created_at',
'g_updated_at',
'g_closed_at',
'g_due_date',
];
/**
* The translatable columns.
*
* @var list<string>
*/
public $translatable = [
'title',
];
/**
* The attributes that should be cast.
*
* @var array<string,string>
*/
#[\Override]
protected $casts = [
'is_closed' => 'boolean',
];
/**
* Perform any actions required after the model boots.
*/
#[\Override]
protected static function booted(): void
{
static::creating(function (self $model): void {
self::manageFields($model);
});
static::updating(function (self $model): void {
self::manageFields($model);
});
}
// * METHODS.
/**
* Manage model fields.
*/
private static function manageFields(self $model): void
{
TranslationHelper::assertTranslationFieldIsUnique($model, $model->title, 'title');
TranslationHelper::validateFallbackTranslations($model);
}
}