This commit is contained in:
2025-05-22 19:15:44 +01:00
parent b0517a18ba
commit 82556535ba
2 changed files with 72 additions and 12 deletions

View File

@@ -3,13 +3,20 @@
namespace App\Models;
use App\Jobs\Services\RunStep;
use Illuminate\Database\Eloquent\Casts\Attribute;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Support\Str;
class Step extends Model
{
protected $guarded = [];
protected $appends = [
'logs_excerpt',
'error_logs_excerpt',
];
protected function casts(): array
{
return [
@@ -24,6 +31,20 @@ class Step extends Model
return $this->belongsTo(Deployment::class);
}
public function logsExcerpt(): Attribute
{
return Attribute::make(
get: fn () => $this->logs ? Str::afterLast($this->logs, "\n"): null,
);
}
public function errorLogsExcerpt(): Attribute
{
return Attribute::make(
get: fn () => $this->error_logs ? Str::afterLast($this->error_logs, "\n"): null,
);
}
public function dispatchJob(): void
{
dispatch(new RunStep($this));