first commit
This commit is contained in:
@@ -0,0 +1,81 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Concerns\HasUlids;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
|
||||
class Issue extends Model
|
||||
{
|
||||
use HasFactory, HasUlids;
|
||||
|
||||
protected $fillable = [
|
||||
'project_id',
|
||||
'fingerprint',
|
||||
'title',
|
||||
'culprit',
|
||||
'level',
|
||||
'status',
|
||||
'first_seen_at',
|
||||
'last_seen_at',
|
||||
'times_seen',
|
||||
'is_regression',
|
||||
'metadata',
|
||||
];
|
||||
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'first_seen_at' => 'datetime',
|
||||
'last_seen_at' => 'datetime',
|
||||
'is_regression' => 'boolean',
|
||||
'metadata' => 'array',
|
||||
];
|
||||
}
|
||||
|
||||
public function project(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Project::class);
|
||||
}
|
||||
|
||||
public function events(): HasMany
|
||||
{
|
||||
return $this->hasMany(Event::class);
|
||||
}
|
||||
|
||||
public function latestEvent(): HasMany
|
||||
{
|
||||
return $this->events()->latest('timestamp')->limit(1);
|
||||
}
|
||||
|
||||
public function resolve(): void
|
||||
{
|
||||
$this->update(['status' => 'resolved', 'is_regression' => false]);
|
||||
}
|
||||
|
||||
public function ignore(): void
|
||||
{
|
||||
$this->update(['status' => 'ignored']);
|
||||
}
|
||||
|
||||
public function mute(): void
|
||||
{
|
||||
$this->update(['status' => 'muted']);
|
||||
}
|
||||
|
||||
public function unresolve(): void
|
||||
{
|
||||
$this->update(['status' => 'unresolved']);
|
||||
}
|
||||
|
||||
public function markRegression(): void
|
||||
{
|
||||
$this->update([
|
||||
'status' => 'unresolved',
|
||||
'is_regression' => true,
|
||||
]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user