47 lines
1.1 KiB
PHP
Executable File
47 lines
1.1 KiB
PHP
Executable File
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Builder;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Prunable;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
|
|
class SupportTicket extends Model
|
|
{
|
|
use Prunable;
|
|
|
|
protected $fillable = [
|
|
'user_id', 'assigned_to', 'reference', 'name', 'email', 'category',
|
|
'subject', 'message', 'status', 'priority', 'privacy_notice_accepted_at',
|
|
'resolved_at',
|
|
];
|
|
|
|
protected function casts(): array
|
|
{
|
|
return [
|
|
'privacy_notice_accepted_at' => 'datetime',
|
|
'resolved_at' => 'datetime',
|
|
];
|
|
}
|
|
|
|
public function user(): BelongsTo
|
|
{
|
|
return $this->belongsTo(User::class);
|
|
}
|
|
|
|
public function assignee(): BelongsTo
|
|
{
|
|
return $this->belongsTo(User::class, 'assigned_to');
|
|
}
|
|
|
|
public function prunable(): Builder
|
|
{
|
|
$days = max(30, (int) config('sonardesk.privacy.support_retention_days', 730));
|
|
|
|
return static::query()
|
|
->whereNotNull('resolved_at')
|
|
->where('resolved_at', '<=', now()->subDays($days));
|
|
}
|
|
}
|