summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSam Light <sam@lightscale.co.uk>2025-04-09 22:22:35 +0100
committerSam Light <samlight1994@gmail.com>2025-04-09 22:22:35 +0100
commitcddc63b8bf3ea2752b08d5a7d7af07e5337d9a48 (patch)
tree0ff802210fd4de73ced32ee0295426215e6e79a8 /src
parent8fc18a9ee68e9f501936360ca18fc1a795cbfc44 (diff)
Moved model
Diffstat (limited to 'src')
-rw-r--r--src/Models/AccessLog.php (renamed from src/Http/Models/AccessLog.php)17
1 files changed, 14 insertions, 3 deletions
diff --git a/src/Http/Models/AccessLog.php b/src/Models/AccessLog.php
index cdfef4b..0c177a3 100644
--- a/src/Http/Models/AccessLog.php
+++ b/src/Models/AccessLog.php
@@ -3,12 +3,17 @@
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 array $guarded = [
+ protected $guarded = [
'user_id'
];
@@ -19,15 +24,21 @@ class AccessLog extends Model
parent::__construct($attributes);
}
- protected function cast(): array
+ 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));
+ }
}