41 lines
1.2 KiB
PHP
41 lines
1.2 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Modules\Helpdesk\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
use Illuminate\Database\Eloquent\Relations\HasMany;
|
|
|
|
final class GitRepository extends Model
|
|
{
|
|
|
|
protected $table = 'helpdesk_git_repositories';
|
|
|
|
/** @var list<string> */
|
|
protected $fillable = ['company_id', 'project_id', 'name', 'provider', 'remote_url', 'default_branch', 'webhook_secret', 'is_active'];
|
|
|
|
/** @var array<string, string> */
|
|
protected $casts = ['company_id' => 'integer', 'project_id' => 'integer', 'is_active' => 'boolean'];
|
|
|
|
/** @return BelongsTo<Project, GitRepository> */
|
|
public function project(): BelongsTo
|
|
{
|
|
return $this->belongsTo(Project::class, 'project_id');
|
|
}
|
|
|
|
/** @return HasMany<GitCommit> */
|
|
public function commits(): HasMany
|
|
{
|
|
return $this->hasMany(GitCommit::class, 'repository_id')->latest('committed_at');
|
|
}
|
|
|
|
/** @return HasMany<GitWebhookLog> */
|
|
public function webhookLogs(): HasMany
|
|
{
|
|
return $this->hasMany(GitWebhookLog::class, 'repository_id')->latest('received_at');
|
|
}
|
|
}
|