chore: code refactor via rector
This commit is contained in:
@@ -2,7 +2,6 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Exception;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
@@ -20,7 +19,7 @@ class Ticket extends Model
|
||||
{
|
||||
parent::boot();
|
||||
|
||||
static::creating(function ($ticket) {
|
||||
static::creating(function ($ticket): void {
|
||||
if (empty($ticket->ticket_id)) {
|
||||
$ticket->ticket_id = 'TICKET-'.strtoupper(Str::random(6));
|
||||
}
|
||||
@@ -46,7 +45,7 @@ class Ticket extends Model
|
||||
public static function autoClose(): bool
|
||||
{
|
||||
try {
|
||||
$tickets = Ticket::where('status', 'pending')
|
||||
$tickets = Ticket::query()->where('status', 'pending')
|
||||
->where('last_response_at', '<', now()->subDays(3))
|
||||
->get();
|
||||
if (count($tickets) > 0) {
|
||||
@@ -54,7 +53,7 @@ class Ticket extends Model
|
||||
$ticket->status = 'closed';
|
||||
$ticket->save();
|
||||
|
||||
TicketResponse::create([
|
||||
TicketResponse::query()->create([
|
||||
'ticket_id' => $ticket->id,
|
||||
'user_id' => 1,
|
||||
'response' => 'This ticket has been auto-closed due to inactivity.',
|
||||
@@ -63,7 +62,7 @@ class Ticket extends Model
|
||||
}
|
||||
|
||||
return true;
|
||||
} catch (Exception $e) {
|
||||
} catch (Exception) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user