38 lines
757 B
PHP
38 lines
757 B
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
use Illuminate\Database\Eloquent\Relations\HasMany;
|
|
|
|
class JobRun extends Model
|
|
{
|
|
protected $fillable = [
|
|
"job_id",
|
|
"success",
|
|
];
|
|
|
|
protected $casts = [
|
|
"success" => "boolean",
|
|
];
|
|
|
|
protected $with = ['artifacts'];
|
|
|
|
public function job(): BelongsTo
|
|
{
|
|
return $this->belongsTo(Job::class);
|
|
}
|
|
|
|
public function artifacts(): HasMany
|
|
{
|
|
return $this->hasMany(JobArtifact::class);
|
|
}
|
|
|
|
public function addArtifact(JobArtifact $artifact): void
|
|
{
|
|
$this->artifacts()->save($artifact);
|
|
}
|
|
}
|