From a019e3b864c28bfba2e75cbbc64439c01345d82c Mon Sep 17 00:00:00 2001 From: kyledoesdev Date: Tue, 6 Jan 2026 18:33:53 -0500 Subject: [PATCH 1/3] added stats concern and default stat --- composer.json | 5 ++-- src/Concerns/HasStatsAfterEvents.php | 34 ++++++++++++++++++++++++++++ src/Stats/LoginStat.php | 7 ++++++ 3 files changed, 44 insertions(+), 2 deletions(-) create mode 100644 src/Concerns/HasStatsAfterEvents.php create mode 100644 src/Stats/LoginStat.php diff --git a/composer.json b/composer.json index 5cf7ebd..5a9db89 100644 --- a/composer.json +++ b/composer.json @@ -18,9 +18,10 @@ "require": { "php": "^8.4", "illuminate/contracts": "^12.0", - "illuminate/support": "^12.0", "illuminate/http": "^12.0", - "spatie/laravel-package-tools": "^1.16" + "illuminate/support": "^12.0", + "spatie/laravel-package-tools": "^1.16", + "spatie/laravel-stats": "^2.3" }, "require-dev": { "laravel/pint": "^1.14", diff --git a/src/Concerns/HasStatsAfterEvents.php b/src/Concerns/HasStatsAfterEvents.php new file mode 100644 index 0000000..c650c3c --- /dev/null +++ b/src/Concerns/HasStatsAfterEvents.php @@ -0,0 +1,34 @@ + StatsWriter::for(StatsEvent::class, ['name' => $model::statsClass()])->increase()); + }); + + static::deleted(function (Model $model) { + dispatch(fn() => StatsWriter::for(StatsEvent::class, ['name' => $model::statsClass()])->decrease()); + }); + } + + public static function statsQuery(): StatsQuery + { + return StatsQuery::for(StatsEvent::class, [ + 'name' => static::statsClass(), + ]); + } + + public static function statsClass(): string + { + return static::class; + } +} \ No newline at end of file diff --git a/src/Stats/LoginStat.php b/src/Stats/LoginStat.php new file mode 100644 index 0000000..55bbdbf --- /dev/null +++ b/src/Stats/LoginStat.php @@ -0,0 +1,7 @@ + Date: Tue, 6 Jan 2026 18:36:21 -0500 Subject: [PATCH 2/3] added is developer middleware --- src/Middleware/IsDeveloper.php | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 src/Middleware/IsDeveloper.php diff --git a/src/Middleware/IsDeveloper.php b/src/Middleware/IsDeveloper.php new file mode 100644 index 0000000..5ae9abf --- /dev/null +++ b/src/Middleware/IsDeveloper.php @@ -0,0 +1,19 @@ +check() && ! auth()->user()->is_dev) { + abort(403); + } + + return $next($request); + } +} \ No newline at end of file From d422cf2bcce8a3b60edda2e74b71be78d4cf7679 Mon Sep 17 00:00:00 2001 From: kyledoesdev Date: Tue, 6 Jan 2026 18:42:15 -0500 Subject: [PATCH 3/3] add toSafeFileName helper --- src/Libraries/helpers.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/Libraries/helpers.php b/src/Libraries/helpers.php index 8d882dd..786b9f9 100644 --- a/src/Libraries/helpers.php +++ b/src/Libraries/helpers.php @@ -1,5 +1,6 @@ ascii() + ->replace(['/', '\\', ':', '*', '?', '"', '<', '>', '|'], '-') + ->trim() + ->toString(); + } +}