first commit
This commit is contained in:
@@ -0,0 +1,62 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Concerns\HasUlids;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
class Event extends Model
|
||||
{
|
||||
use HasUlids;
|
||||
|
||||
const UPDATED_AT = null;
|
||||
|
||||
protected $fillable = [
|
||||
'issue_id',
|
||||
'project_id',
|
||||
'event_id',
|
||||
'level',
|
||||
'message',
|
||||
'platform',
|
||||
'timestamp',
|
||||
'server_name',
|
||||
'release',
|
||||
'environment',
|
||||
'exception',
|
||||
'breadcrumbs',
|
||||
'contexts',
|
||||
'tags',
|
||||
'extra',
|
||||
'user_context',
|
||||
'request_context',
|
||||
'sdk',
|
||||
'raw_payload',
|
||||
];
|
||||
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'timestamp' => 'datetime',
|
||||
'exception' => 'array',
|
||||
'breadcrumbs' => 'array',
|
||||
'contexts' => 'array',
|
||||
'tags' => 'array',
|
||||
'extra' => 'array',
|
||||
'user_context' => 'array',
|
||||
'request_context' => 'array',
|
||||
'sdk' => 'array',
|
||||
'raw_payload' => 'array',
|
||||
];
|
||||
}
|
||||
|
||||
public function issue(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Issue::class);
|
||||
}
|
||||
|
||||
public function project(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Project::class);
|
||||
}
|
||||
}
|
||||
@@ -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,
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
<?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\BelongsToMany;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class Project extends Model
|
||||
{
|
||||
use HasFactory, HasUlids;
|
||||
|
||||
protected $fillable = [
|
||||
'name',
|
||||
'platform',
|
||||
];
|
||||
|
||||
protected static function booted(): void
|
||||
{
|
||||
static::creating(function (Project $project) {
|
||||
$project->dsn_public_key ??= Str::uuid()->toString();
|
||||
$project->dsn_secret_key ??= Str::uuid()->toString();
|
||||
});
|
||||
}
|
||||
|
||||
public function getDsnAttribute(): string
|
||||
{
|
||||
$host = config('app.url');
|
||||
|
||||
return "{$host}/api/{$this->id}/store/?sentry_key={$this->dsn_public_key}";
|
||||
}
|
||||
|
||||
public function users(): BelongsToMany
|
||||
{
|
||||
return $this->belongsToMany(User::class)
|
||||
->withPivot('role')
|
||||
->withTimestamps();
|
||||
}
|
||||
|
||||
public function issues(): HasMany
|
||||
{
|
||||
return $this->hasMany(Issue::class);
|
||||
}
|
||||
|
||||
public function events(): HasMany
|
||||
{
|
||||
return $this->hasMany(Event::class);
|
||||
}
|
||||
|
||||
public function regenerateKeys(): void
|
||||
{
|
||||
$this->update([
|
||||
'dsn_public_key' => Str::uuid()->toString(),
|
||||
'dsn_secret_key' => Str::uuid()->toString(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
// use Illuminate\Contracts\Auth\MustVerifyEmail;
|
||||
use Database\Factories\UserFactory;
|
||||
use Illuminate\Database\Eloquent\Attributes\Fillable;
|
||||
use Illuminate\Database\Eloquent\Attributes\Hidden;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
||||
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||
use Illuminate\Notifications\Notifiable;
|
||||
|
||||
#[Fillable(['name', 'email', 'password'])]
|
||||
#[Hidden(['password', 'remember_token'])]
|
||||
class User extends Authenticatable
|
||||
{
|
||||
/** @use HasFactory<UserFactory> */
|
||||
use HasFactory, Notifiable;
|
||||
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'email_verified_at' => 'datetime',
|
||||
'password' => 'hashed',
|
||||
];
|
||||
}
|
||||
|
||||
public function projects(): BelongsToMany
|
||||
{
|
||||
return $this->belongsToMany(Project::class)
|
||||
->withPivot('role')
|
||||
->withTimestamps();
|
||||
}
|
||||
|
||||
public function ownedProjects(): BelongsToMany
|
||||
{
|
||||
return $this->projects()->wherePivot('role', 'owner');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user