53 lines
1.3 KiB
PHP
53 lines
1.3 KiB
PHP
<?php
|
|
|
|
namespace App\Domains\Ticket\Models;
|
|
|
|
use App\Domains\Auth\Models\User;
|
|
use App\Domains\Tenant\Models\Tenant;
|
|
use App\Domains\Ticket\Enums\ScanAttemptResult;
|
|
use Illuminate\Database\Eloquent\Attributes\Fillable;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
|
|
#[Fillable([
|
|
'tenant_code',
|
|
'scanner_user_id',
|
|
'ticket_id',
|
|
'data',
|
|
'result',
|
|
'resolved_at',
|
|
])]
|
|
class ScanAttempt extends Model
|
|
{
|
|
public const UPDATED_AT = null;
|
|
|
|
/** @return BelongsTo<User, $this> */
|
|
public function scanner(): BelongsTo
|
|
{
|
|
return $this->belongsTo(User::class, 'scanner_user_id')->withTrashed();
|
|
}
|
|
|
|
/** @return BelongsTo<Ticket, $this> */
|
|
public function ticket(): BelongsTo
|
|
{
|
|
return $this->belongsTo(Ticket::class);
|
|
}
|
|
|
|
/** @return BelongsTo<Tenant, $this> */
|
|
public function tenant(): BelongsTo
|
|
{
|
|
return $this->belongsTo(Tenant::class, 'tenant_code', 'codigo');
|
|
}
|
|
|
|
protected function casts(): array
|
|
{
|
|
return [
|
|
'scanner_user_id' => 'integer',
|
|
'ticket_id' => 'integer',
|
|
'result' => ScanAttemptResult::class,
|
|
'created_at' => 'datetime',
|
|
'resolved_at' => 'datetime',
|
|
];
|
|
}
|
|
}
|