chore: code refactor via rector

This commit is contained in:
idevakk
2025-11-14 02:01:01 -08:00
parent 90ab79b3a2
commit ae795880ed
148 changed files with 1520 additions and 1486 deletions

View File

@@ -2,7 +2,7 @@
namespace App\Models;
use Carbon\Carbon;
use Illuminate\Support\Facades\Date;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
@@ -26,15 +26,14 @@ class Log extends Model
return $this->belongsTo(User::class);
}
public static function deleteLogsFromDB()
public static function deleteLogsFromDB(): string
{
$cutoff = Carbon::now('UTC')->subMonths(3)->toDateTimeString();
$count = count(self::where('created_at', '<', $cutoff)
->orderBy('created_at', 'desc')
$cutoff = Date::now('UTC')->subMonths(3)->toDateTimeString();
$count = count(self::query()->where('created_at', '<', $cutoff)->latest()
->get());
if ($count > 0) {
self::where('created_at', '<', $cutoff)->delete();
self::query()->where('created_at', '<', $cutoff)->delete();
return "$count old log(s) deleted from the database.";
}