From cddc63b8bf3ea2752b08d5a7d7af07e5337d9a48 Mon Sep 17 00:00:00 2001
From: Sam Light <sam@lightscale.co.uk>
Date: Wed, 9 Apr 2025 22:22:35 +0100
Subject: Moved model

---
 src/Http/Models/AccessLog.php | 33 --------------------------------
 src/Models/AccessLog.php      | 44 +++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 44 insertions(+), 33 deletions(-)
 delete mode 100644 src/Http/Models/AccessLog.php
 create mode 100644 src/Models/AccessLog.php

(limited to 'src')

diff --git a/src/Http/Models/AccessLog.php b/src/Http/Models/AccessLog.php
deleted file mode 100644
index cdfef4b..0000000
--- a/src/Http/Models/AccessLog.php
+++ /dev/null
@@ -1,33 +0,0 @@
-<?php
-
-namespace Lightscale\LaralightAccessLog\Models;
-
-use Illuminate\Database\Eloquent\Model;
-
-class AccessLog extends Model
-{
-    const UPDATED_AT = null;
-
-    protected array $guarded = [
-        'user_id'
-    ];
-
-    public function __construct(array $attributes = [])
-    {
-        $this->setTable(config('access_log.table_name'));
-
-        parent::__construct($attributes);
-    }
-
-    protected function cast(): array
-    {
-        return [
-            'properties' => 'collection',
-        ]
-    }
-
-    public function user(): BelongsTo
-    {
-        return $this->belongsTo(config('access_log.user_model'));
-    }
-}
diff --git a/src/Models/AccessLog.php b/src/Models/AccessLog.php
new file mode 100644
index 0000000..0c177a3
--- /dev/null
+++ b/src/Models/AccessLog.php
@@ -0,0 +1,44 @@
+<?php
+
+namespace Lightscale\LaralightAccessLog\Models;
+
+use Illuminate\Database\Eloquent\Model;
+use Illuminate\Database\Eloquent\Relations\BelongsTo;
+use Illuminate\Database\Eloquent\Prunable;
+use Illuminate\Database\Eloquent\Builder;
+
+class AccessLog extends Model
+{
+    use Prunable;
+
+    const UPDATED_AT = null;
+
+    protected $guarded = [
+        'user_id'
+    ];
+
+    public function __construct(array $attributes = [])
+    {
+        $this->setTable(config('access_log.table_name'));
+
+        parent::__construct($attributes);
+    }
+
+    protected function casts(): array
+    {
+        return [
+            'properties' => 'collection',
+        ];
+    }
+
+    public function user(): BelongsTo
+    {
+        return $this->belongsTo(config('access_log.user_model'));
+    }
+
+    public function prunable(): Builder
+    {
+        $days = config('access_log.max_age_days');
+        return static::where(static::CREATED_AT, '<=', now()->subDays($days));
+    }
+}
-- 
cgit v1.2.3