Add complete feature suite: Permissions, Audit Trail, API Auth, Error Tracking, Module System, and Site Settings
- Install spatie/laravel-permission v6.24 with 3 roles (admin, editor, viewer) and 5 base permissions - Install owen-it/laravel-auditing v14.0 for tracking model changes - Install laravel/sanctum v4.3 for API token authentication - Install spatie/laravel-ignition v2.11 and spatie/flare-client-php v1.10 for enhanced error tracking - Add Module System with make:module artisan command for scaffolding features - Create Site Settings page in Filament admin for logo, colors, and configuration - Add comprehensive debugging documentation (DEBUGGING.md, AI_CONTEXT.md updates) - Create FEATURES.md with complete feature reference - Update User model with HasRoles and HasApiTokens traits - Configure Redis cache and OPcache for performance - Add RolePermissionSeeder with pre-configured roles and permissions - Update documentation with debugging-first workflow - All features pre-installed and production-ready
This commit is contained in:
38
src/app/Models/Setting.php
Normal file
38
src/app/Models/Setting.php
Normal file
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Setting extends Model
|
||||
{
|
||||
protected $fillable = ['key', 'value', 'type'];
|
||||
|
||||
public static function get(string $key, $default = null)
|
||||
{
|
||||
$setting = static::where('key', $key)->first();
|
||||
|
||||
if (!$setting) {
|
||||
return $default;
|
||||
}
|
||||
|
||||
return match ($setting->type) {
|
||||
'boolean' => filter_var($setting->value, FILTER_VALIDATE_BOOLEAN),
|
||||
'integer' => (int) $setting->value,
|
||||
'array', 'json' => json_decode($setting->value, true),
|
||||
default => $setting->value,
|
||||
};
|
||||
}
|
||||
|
||||
public static function set(string $key, $value, string $type = 'string'): void
|
||||
{
|
||||
if (in_array($type, ['array', 'json'])) {
|
||||
$value = json_encode($value);
|
||||
}
|
||||
|
||||
static::updateOrCreate(
|
||||
['key' => $key],
|
||||
['value' => $value, 'type' => $type]
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -6,11 +6,13 @@
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||
use Illuminate\Notifications\Notifiable;
|
||||
use Laravel\Sanctum\HasApiTokens;
|
||||
use Spatie\Permission\Traits\HasRoles;
|
||||
|
||||
class User extends Authenticatable
|
||||
{
|
||||
/** @use HasFactory<\Database\Factories\UserFactory> */
|
||||
use HasFactory, Notifiable;
|
||||
use HasFactory, Notifiable, HasRoles, HasApiTokens;
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
|
||||
Reference in New Issue
Block a user