66 lines
1.9 KiB
PHP
66 lines
1.9 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use App\Traits\Auditable;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
class Ticket extends Model
|
|
{
|
|
use Auditable;
|
|
|
|
protected $fillable = [
|
|
'ticket_no',
|
|
'ticket_type_id',
|
|
'customer_id',
|
|
'source','installation_step','verified_by','verified_at','verification_notes',
|
|
'title',
|
|
'description',
|
|
'priority',
|
|
'status',
|
|
'created_by',
|
|
'assigned_at',
|
|
'approved_by',
|
|
'approved_at',
|
|
'rejected_by',
|
|
'rejected_at',
|
|
'rejection_reason',
|
|
'resolved_at',
|
|
'closed_at',
|
|
'tenant_id',
|
|
];
|
|
|
|
protected function casts(): array
|
|
{
|
|
return [
|
|
'assigned_at' => 'datetime',
|
|
'resolved_at' => 'datetime',
|
|
'closed_at' => 'datetime',
|
|
'verified_at' => 'datetime',
|
|
];
|
|
}
|
|
|
|
/*
|
|
|--------------------------------------------------------------------------
|
|
| Relationships
|
|
|--------------------------------------------------------------------------
|
|
*/
|
|
|
|
public function ticketType()
|
|
{
|
|
return $this->belongsTo(
|
|
TicketType::class,
|
|
'ticket_type_id'
|
|
);
|
|
}
|
|
|
|
|
|
public function customer() { return $this->belongsTo(Customer::class); }
|
|
public function tenant() { return $this->belongsTo(Tenant::class); }
|
|
public function creator() { return $this->belongsTo(User::class, 'created_by'); }
|
|
public function assignments() { return $this->hasMany(TicketAssignment::class); }
|
|
public function logs() { return $this->hasMany(TicketLog::class)->orderByDesc('id'); }
|
|
public function materials() { return $this->hasMany(TicketMaterial::class)->with('user:id,name')->orderByDesc('id'); }
|
|
public function attachments() { return $this->hasMany(TicketAttachment::class)->with('file:id,uuid,original_name,mime_type,size')->orderBy('id'); }
|
|
}
|