105 lines
3.6 KiB
PHP
105 lines
3.6 KiB
PHP
<?php
|
|
|
|
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 integer $id Primary key of the gitlab issue.
|
|
* @property string $name Name of the gitlab issue.
|
|
* @property string $url Url of the gitlab issue.
|
|
* @property string $estimate_time Estimate time of the gitlab issue.
|
|
* @property string $spent_time Spend time of the gitlab issue.
|
|
* @property string $is_closed Closed status of the gitlab issue.
|
|
* @property string $gitlab_id Gitlab id of the gitlab issue.
|
|
* @property string $gitlab_iid Gitlab iid of the gitlab issue.
|
|
* @property string $milestone_iid Milestone iid of the gitlab issue.
|
|
* @property string $gitlab_project_id Gitlab project id of the gitlab issue.
|
|
* @property string $g_created_at Created at date of the gitlab issue.
|
|
* @property string $g_updated_at Updated at date of the gitlab issue.
|
|
* @property string $g_closed_at Closed at date of the gitlab issue.
|
|
* @property string $g_due_date Due at date of the gitlab issue.
|
|
* @property-read \Illuminate\Support\Carbon $created_at Date the gitlab issue was created.
|
|
* @property-read \Illuminate\Support\Carbon $updated_at Date the gitlab issue was updated.
|
|
* @property-read \Illuminate\Support\Carbon $deleted_at Date the gitlab issue was deleted.
|
|
*/
|
|
class GitlabIssue extends Model implements TranslatableModel
|
|
{
|
|
use HasActivityLog;
|
|
/** @use \Illuminate\Database\Eloquent\Factories\HasFactory<\Database\Factories\GitlabIssueFactory> */
|
|
use HasFactory;
|
|
use HasTranslations;
|
|
|
|
/**
|
|
* The attributes that are mass assignable.
|
|
*
|
|
* @var list<string>
|
|
*/
|
|
protected $fillable = [
|
|
"title",
|
|
"url",
|
|
"estimate_time",
|
|
"spent_time",
|
|
"is_closed",
|
|
"gitlab_id",
|
|
"gitlab_iid",
|
|
"milestone_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>
|
|
*/
|
|
protected $casts = [
|
|
'is_closed' => 'boolean',
|
|
];
|
|
|
|
/**
|
|
* Perform any actions required after the model boots.
|
|
*
|
|
* @return void
|
|
*/
|
|
protected static function booted(): void
|
|
{
|
|
static::creating(function (self $model) {
|
|
self::manageFields($model);
|
|
});
|
|
static::updating(function (self $model) {
|
|
self::manageFields($model);
|
|
});
|
|
}
|
|
|
|
// * METHODS.
|
|
|
|
/**
|
|
* Manage model fields.
|
|
*
|
|
* @param self $model
|
|
* @return void
|
|
*/
|
|
private static function manageFields(self $model): void
|
|
{
|
|
TranslationHelper::assertTranslationFieldIsUnique($model, $model->title, 'title');
|
|
TranslationHelper::validateFallbackTranslations($model);
|
|
}
|
|
}
|