Add admin audit log viewer and system settings

Phase 5 (Admin Panel):
- Audit log viewer: searchable with action/date filters, expandable
  rows showing JSON changes, color-coded action chips, user avatars
- System settings: tabbed page (General, API Credentials, Billing,
  Notifications) with masked sensitive values, per-group save
- Settings model with get/set/getGroup/setGroup helpers
- Settings migration for key-value store with groups
- 52 tests passing, build clean

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Claude Dev
2026-02-09 10:45:31 -05:00
parent d9ec414264
commit 813fde30c2
9 changed files with 1345 additions and 0 deletions

View File

@@ -0,0 +1,62 @@
<?php
declare(strict_types=1);
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class Setting extends Model
{
protected $fillable = [
'key',
'value',
'group',
];
/**
* Get a setting value by key.
*/
public static function get(string $key, mixed $default = null): mixed
{
$setting = static::query()->where('key', $key)->first();
return $setting?->value ?? $default;
}
/**
* Set a setting value by key.
*/
public static function set(string $key, mixed $value, string $group = 'general'): void
{
static::query()->updateOrCreate(
['key' => $key],
['value' => $value, 'group' => $group],
);
}
/**
* Get all settings for a given group as a key-value array.
*
* @return array<string, string|null>
*/
public static function getGroup(string $group): array
{
return static::query()
->where('group', $group)
->pluck('value', 'key')
->toArray();
}
/**
* Set multiple settings at once for a given group.
*
* @param array<string, string|null> $settings
*/
public static function setGroup(string $group, array $settings): void
{
foreach ($settings as $key => $value) {
static::set($key, $value, $group);
}
}
}