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:
2026-03-09 09:34:10 +02:00
parent a55fafd3a9
commit ae410ca4da
26 changed files with 2501 additions and 35 deletions

View File

@@ -26,7 +26,7 @@ DB_DATABASE=laravel
DB_USERNAME=laravel
DB_PASSWORD=secret
SESSION_DRIVER=redis
SESSION_DRIVER=database
SESSION_LIFETIME=120
SESSION_ENCRYPT=false
SESSION_PATH=/

View File

@@ -26,7 +26,7 @@ DB_DATABASE=laravel
DB_USERNAME=laravel
DB_PASSWORD=secret
SESSION_DRIVER=redis
SESSION_DRIVER=database
SESSION_LIFETIME=120
SESSION_ENCRYPT=false
SESSION_PATH=/

View File

@@ -22,7 +22,7 @@ LOG_LEVEL=debug
DB_CONNECTION=sqlite
DB_DATABASE=/var/www/html/database/database.sqlite
SESSION_DRIVER=redis
SESSION_DRIVER=database
SESSION_LIFETIME=120
SESSION_ENCRYPT=false
SESSION_PATH=/

View File

@@ -0,0 +1,336 @@
<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\File;
use Illuminate\Support\Str;
class MakeModuleCommand extends Command
{
protected $signature = 'make:module {name : The name of the module}';
protected $description = 'Create a new module with standard structure';
public function handle(): int
{
$name = $this->argument('name');
$studlyName = Str::studly($name);
$kebabName = Str::kebab($name);
$modulePath = app_path("Modules/{$studlyName}");
if (File::exists($modulePath)) {
$this->error("Module {$studlyName} already exists!");
return self::FAILURE;
}
$this->info("Creating module: {$studlyName}");
$this->createDirectories($modulePath);
$this->createModel($modulePath, $studlyName);
$this->createMigration($studlyName);
$this->createController($modulePath, $studlyName);
$this->createRoutes($modulePath, $studlyName, $kebabName);
$this->createViews($modulePath, $studlyName, $kebabName);
$this->createFilamentResource($studlyName);
$this->createTests($studlyName);
$this->info("\n✅ Module {$studlyName} created successfully!");
$this->info("\nNext steps:");
$this->info("1. Run migrations: php artisan migrate");
$this->info("2. Register routes in routes/web.php:");
$this->info(" require __DIR__.'/../app/Modules/{$studlyName}/routes.php';");
$this->info("3. Access at: /{$kebabName}");
return self::SUCCESS;
}
protected function createDirectories(string $path): void
{
File::makeDirectory($path, 0755, true);
File::makeDirectory("{$path}/Models", 0755, true);
File::makeDirectory("{$path}/Controllers", 0755, true);
File::makeDirectory("{$path}/Views", 0755, true);
}
protected function createModel(string $path, string $name): void
{
$stub = <<<PHP
<?php
namespace App\Modules\\{$name}\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Factories\HasFactory;
class {$name} extends Model
{
use HasFactory;
protected \$fillable = [
'name',
'description',
];
}
PHP;
File::put("{$path}/Models/{$name}.php", $stub);
$this->info("✓ Created Model: {$name}");
}
protected function createMigration(string $name): void
{
$table = Str::snake(Str::plural($name));
$timestamp = date('Y_m_d_His');
$migrationName = "create_{$table}_table";
$stub = <<<PHP
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
public function up(): void
{
Schema::create('{$table}', function (Blueprint \$table) {
\$table->id();
\$table->string('name');
\$table->text('description')->nullable();
\$table->timestamps();
});
}
public function down(): void
{
Schema::dropIfExists('{$table}');
}
};
PHP;
$migrationPath = database_path("migrations/{$timestamp}_{$migrationName}.php");
File::put($migrationPath, $stub);
$this->info("✓ Created Migration: {$migrationName}");
}
protected function createController(string $path, string $name): void
{
$plural = Str::plural($name);
$variable = Str::camel($name);
$pluralVariable = Str::camel($plural);
$stub = <<<PHP
<?php
namespace App\Modules\\{$name}\Controllers;
use App\Http\Controllers\Controller;
use App\Modules\\{$name}\Models\\{$name};
use Illuminate\Http\Request;
class {$name}Controller extends Controller
{
public function index()
{
\${$pluralVariable} = {$name}::latest()->paginate(15);
return view('{$name}::index', compact('{$pluralVariable}'));
}
public function create()
{
return view('{$name}::create');
}
public function store(Request \$request)
{
\$validated = \$request->validate([
'name' => 'required|string|max:255',
'description' => 'nullable|string',
]);
{$name}::create(\$validated);
return redirect()->route('{$variable}.index')
->with('success', '{$name} created successfully.');
}
public function show({$name} \${$variable})
{
return view('{$name}::show', compact('{$variable}'));
}
public function edit({$name} \${$variable})
{
return view('{$name}::edit', compact('{$variable}'));
}
public function update(Request \$request, {$name} \${$variable})
{
\$validated = \$request->validate([
'name' => 'required|string|max:255',
'description' => 'nullable|string',
]);
\${$variable}->update(\$validated);
return redirect()->route('{$variable}.index')
->with('success', '{$name} updated successfully.');
}
public function destroy({$name} \${$variable})
{
\${$variable}->delete();
return redirect()->route('{$variable}.index')
->with('success', '{$name} deleted successfully.');
}
}
PHP;
File::put("{$path}/Controllers/{$name}Controller.php", $stub);
$this->info("✓ Created Controller: {$name}Controller");
}
protected function createRoutes(string $path, string $name, string $kebabName): void
{
$variable = Str::camel($name);
$stub = <<<PHP
<?php
use Illuminate\Support\Facades\Route;
use App\Modules\\{$name}\Controllers\\{$name}Controller;
Route::middleware(['web', 'auth'])->group(function () {
Route::resource('{$kebabName}', {$name}Controller::class)->names('{$variable}');
});
PHP;
File::put("{$path}/routes.php", $stub);
$this->info("✓ Created Routes");
}
protected function createViews(string $path, string $name, string $kebabName): void
{
$plural = Str::plural($name);
$variable = Str::camel($name);
$pluralVariable = Str::camel($plural);
$indexView = <<<BLADE
<x-app-layout>
<x-slot name="header">
<h2 class="font-semibold text-xl text-gray-800 leading-tight">
{{ __('{$plural}') }}
</h2>
</x-slot>
<div class="py-12">
<div class="max-w-7xl mx-auto sm:px-6 lg:px-8">
<div class="bg-white overflow-hidden shadow-sm sm:rounded-lg">
<div class="p-6 text-gray-900">
<div class="flex justify-between mb-4">
<h3 class="text-lg font-semibold">{$plural} List</h3>
<a href="{{ route('{$variable}.create') }}" class="bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded">
Create New
</a>
</div>
@if(session('success'))
<div class="bg-green-100 border border-green-400 text-green-700 px-4 py-3 rounded mb-4">
{{ session('success') }}
</div>
@endif
<table class="min-w-full divide-y divide-gray-200">
<thead class="bg-gray-50">
<tr>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase">Name</th>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase">Description</th>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase">Actions</th>
</tr>
</thead>
<tbody class="bg-white divide-y divide-gray-200">
@forelse(\${$pluralVariable} as \${$variable})
<tr>
<td class="px-6 py-4">{{ \${$variable}->name }}</td>
<td class="px-6 py-4">{{ \${$variable}->description }}</td>
<td class="px-6 py-4">
<a href="{{ route('{$variable}.edit', \${$variable}) }}" class="text-blue-600 hover:text-blue-900">Edit</a>
<form action="{{ route('{$variable}.destroy', \${$variable}) }}" method="POST" class="inline">
@csrf
@method('DELETE')
<button type="submit" class="text-red-600 hover:text-red-900 ml-2">Delete</button>
</form>
</td>
</tr>
@empty
<tr>
<td colspan="3" class="px-6 py-4 text-center">No {$pluralVariable} found.</td>
</tr>
@endforelse
</tbody>
</table>
<div class="mt-4">
{{ \${$pluralVariable}->links() }}
</div>
</div>
</div>
</div>
</div>
</x-app-layout>
BLADE;
File::put("{$path}/Views/index.blade.php", $indexView);
$this->info("✓ Created Views");
}
protected function createFilamentResource(string $name): void
{
$this->call('make:filament-resource', [
'name' => $name,
'--generate' => true,
]);
}
protected function createTests(string $name): void
{
$variable = Str::camel($name);
$stub = <<<PHP
<?php
use App\Modules\\{$name}\Models\\{$name};
use App\Models\User;
it('can list {$variable}s', function () {
\$user = User::factory()->create();
{$name}::factory()->count(3)->create();
\$response = \$this->actingAs(\$user)->get(route('{$variable}.index'));
\$response->assertStatus(200);
});
it('can create {$variable}', function () {
\$user = User::factory()->create();
\$response = \$this->actingAs(\$user)->post(route('{$variable}.store'), [
'name' => 'Test {$name}',
'description' => 'Test description',
]);
\$response->assertRedirect(route('{$variable}.index'));
\$this->assertDatabaseHas('{$variable}s', ['name' => 'Test {$name}']);
});
PHP;
$testPath = base_path("tests/Modules/{$name}");
File::makeDirectory($testPath, 0755, true);
File::put("{$testPath}/{$name}Test.php", $stub);
$this->info("✓ Created Tests");
}
}

View File

@@ -0,0 +1,125 @@
<?php
namespace App\Filament\Pages;
use App\Models\Setting;
use Filament\Forms;
use Filament\Forms\Form;
use Filament\Pages\Page;
use Filament\Actions\Action;
use Filament\Notifications\Notification;
class Settings extends Page
{
protected static ?string $navigationIcon = 'heroicon-o-cog-6-tooth';
protected static string $view = 'filament.pages.settings';
protected static ?string $navigationGroup = 'Settings';
protected static ?int $navigationSort = 99;
public ?array $data = [];
public function mount(): void
{
$siteName = Setting::get('site_name', config('app.name'));
$siteLogo = Setting::get('site_logo');
$primaryColor = Setting::get('primary_color', '#3b82f6');
$secondaryColor = Setting::get('secondary_color', '#8b5cf6');
$accentColor = Setting::get('accent_color', '#10b981');
$siteDescription = Setting::get('site_description');
$contactEmail = Setting::get('contact_email');
$maintenanceMode = Setting::get('maintenance_mode', false);
$this->form->fill([
'site_name' => is_string($siteName) ? $siteName : config('app.name'),
'site_logo' => is_string($siteLogo) || is_null($siteLogo) ? $siteLogo : null,
'primary_color' => is_string($primaryColor) ? $primaryColor : '#3b82f6',
'secondary_color' => is_string($secondaryColor) ? $secondaryColor : '#8b5cf6',
'accent_color' => is_string($accentColor) ? $accentColor : '#10b981',
'site_description' => is_string($siteDescription) || is_null($siteDescription) ? $siteDescription : '',
'contact_email' => is_string($contactEmail) || is_null($contactEmail) ? $contactEmail : '',
'maintenance_mode' => is_bool($maintenanceMode) ? $maintenanceMode : false,
]);
}
public function form(Form $form): Form
{
return $form
->schema([
Forms\Components\Section::make('General Settings')
->schema([
Forms\Components\TextInput::make('site_name')
->label('Site Name')
->required()
->maxLength(255),
Forms\Components\FileUpload::make('site_logo')
->label('Site Logo')
->image()
->directory('logos')
->visibility('public'),
Forms\Components\Textarea::make('site_description')
->label('Site Description')
->rows(3)
->maxLength(500),
Forms\Components\TextInput::make('contact_email')
->label('Contact Email')
->email()
->maxLength(255),
]),
Forms\Components\Section::make('Color Scheme')
->schema([
Forms\Components\ColorPicker::make('primary_color')
->label('Primary Color'),
Forms\Components\ColorPicker::make('secondary_color')
->label('Secondary Color'),
Forms\Components\ColorPicker::make('accent_color')
->label('Accent Color'),
])
->columns(3),
Forms\Components\Section::make('System')
->schema([
Forms\Components\Toggle::make('maintenance_mode')
->label('Maintenance Mode')
->helperText('Enable to put the site in maintenance mode'),
]),
])
->statePath('data');
}
protected function getFormActions(): array
{
return [
Action::make('save')
->label('Save Settings')
->submit('save'),
];
}
public function save(): void
{
$data = $this->form->getState();
Setting::set('site_name', $data['site_name'] ?? '');
Setting::set('site_logo', $data['site_logo'] ?? '');
Setting::set('primary_color', $data['primary_color'] ?? '#3b82f6');
Setting::set('secondary_color', $data['secondary_color'] ?? '#8b5cf6');
Setting::set('accent_color', $data['accent_color'] ?? '#10b981');
Setting::set('site_description', $data['site_description'] ?? '');
Setting::set('contact_email', $data['contact_email'] ?? '');
Setting::set('maintenance_mode', $data['maintenance_mode'] ?? false, 'boolean');
Notification::make()
->title('Settings saved successfully')
->success()
->send();
}
}

View 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]
);
}
}

View File

@@ -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.

94
src/app/Modules/README.md Normal file
View File

@@ -0,0 +1,94 @@
# Module System
This Laravel application uses a modular architecture to organize features into self-contained modules.
## Creating a New Module
Use the artisan command to scaffold a complete module:
```bash
php artisan make:module ProductCatalog
```
This creates:
- **Model**: `app/Modules/ProductCatalog/Models/ProductCatalog.php`
- **Controller**: `app/Modules/ProductCatalog/Controllers/ProductCatalogController.php`
- **Routes**: `app/Modules/ProductCatalog/routes.php`
- **Views**: `app/Modules/ProductCatalog/Views/`
- **Migration**: `database/migrations/YYYY_MM_DD_HHMMSS_create_product_catalogs_table.php`
- **Filament Resource**: `app/Filament/Resources/ProductCatalogResource.php`
- **Tests**: `tests/Modules/ProductCatalog/ProductCatalogTest.php`
## Module Structure
```
app/Modules/
└── ProductCatalog/
├── Models/
│ └── ProductCatalog.php
├── Controllers/
│ └── ProductCatalogController.php
├── Views/
│ ├── index.blade.php
│ ├── create.blade.php
│ ├── edit.blade.php
│ └── show.blade.php
└── routes.php
```
## Registering Module Routes
After creating a module, register its routes in `routes/web.php`:
```php
require __DIR__.'/../app/Modules/ProductCatalog/routes.php';
```
## Module Features
Each module includes:
**CRUD Operations** - Full Create, Read, Update, Delete functionality
**Authentication** - Routes protected by auth middleware
**Filament Admin** - Auto-generated admin panel resource
**Blade Views** - Responsive Tailwind CSS templates
**Tests** - Pest test suite for module functionality
**Permissions** - Ready for role-based access control
## Example Usage
```bash
# Create an Inventory module
php artisan make:module Inventory
# Run migrations
php artisan migrate
# Register routes in routes/web.php
require __DIR__.'/../app/Modules/Inventory/routes.php';
# Access at: http://localhost:8080/inventory
# Admin panel: http://localhost:8080/admin/inventories
```
## Adding Permissions
To add module-specific permissions:
```php
// In database/seeders/RolePermissionSeeder.php
$permissions = [
'inventory.view',
'inventory.create',
'inventory.edit',
'inventory.delete',
];
```
## Best Practices
1. **Keep modules self-contained** - Each module should be independent
2. **Use namespaces** - Follow the `App\Modules\{ModuleName}` pattern
3. **Test your modules** - Run `php artisan test` after creating
4. **Document changes** - Update module README if you modify structure
5. **Use Filament** - Leverage the admin panel for quick CRUD interfaces

View File

@@ -7,6 +7,7 @@
return Application::configure(basePath: dirname(__DIR__))
->withRouting(
web: __DIR__.'/../routes/web.php',
api: __DIR__.'/../routes/api.php',
commands: __DIR__.'/../routes/console.php',
health: '/up',
)

View File

@@ -9,7 +9,12 @@
"php": "^8.2",
"filament/filament": "^3.2",
"laravel/framework": "^11.31",
"laravel/tinker": "^2.9"
"laravel/sanctum": "^4.0",
"laravel/tinker": "^2.9",
"owen-it/laravel-auditing": "^14.0",
"spatie/flare-client-php": "^1.10",
"spatie/laravel-ignition": "^2.11",
"spatie/laravel-permission": "^6.24"
},
"require-dev": {
"fakerphp/faker": "^1.23",

614
src/composer.lock generated
View File

@@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "b298a6d9065deaecdbd05c7bc703b231",
"content-hash": "1f84406b8f4e254677813bb043dd37c3",
"packages": [
{
"name": "anourvalar/eloquent-serialize",
@@ -2296,6 +2296,69 @@
},
"time": "2026-02-06T12:17:10+00:00"
},
{
"name": "laravel/sanctum",
"version": "v4.3.1",
"source": {
"type": "git",
"url": "https://github.com/laravel/sanctum.git",
"reference": "e3b85d6e36ad00e5db2d1dcc27c81ffdf15cbf76"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/laravel/sanctum/zipball/e3b85d6e36ad00e5db2d1dcc27c81ffdf15cbf76",
"reference": "e3b85d6e36ad00e5db2d1dcc27c81ffdf15cbf76",
"shasum": ""
},
"require": {
"ext-json": "*",
"illuminate/console": "^11.0|^12.0|^13.0",
"illuminate/contracts": "^11.0|^12.0|^13.0",
"illuminate/database": "^11.0|^12.0|^13.0",
"illuminate/support": "^11.0|^12.0|^13.0",
"php": "^8.2",
"symfony/console": "^7.0|^8.0"
},
"require-dev": {
"mockery/mockery": "^1.6",
"orchestra/testbench": "^9.15|^10.8|^11.0",
"phpstan/phpstan": "^1.10"
},
"type": "library",
"extra": {
"laravel": {
"providers": [
"Laravel\\Sanctum\\SanctumServiceProvider"
]
}
},
"autoload": {
"psr-4": {
"Laravel\\Sanctum\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Taylor Otwell",
"email": "taylor@laravel.com"
}
],
"description": "Laravel Sanctum provides a featherweight authentication system for SPAs and simple APIs.",
"keywords": [
"auth",
"laravel",
"sanctum"
],
"support": {
"issues": "https://github.com/laravel/sanctum/issues",
"source": "https://github.com/laravel/sanctum"
},
"time": "2026-02-07T17:19:31+00:00"
},
{
"name": "laravel/serializable-closure",
"version": "v2.0.10",
@@ -3820,6 +3883,90 @@
],
"time": "2025-09-03T16:03:54+00:00"
},
{
"name": "owen-it/laravel-auditing",
"version": "v14.0.0",
"source": {
"type": "git",
"url": "https://github.com/owen-it/laravel-auditing.git",
"reference": "f92602d1b3f53df29ddd577290e9d735ea707c53"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/owen-it/laravel-auditing/zipball/f92602d1b3f53df29ddd577290e9d735ea707c53",
"reference": "f92602d1b3f53df29ddd577290e9d735ea707c53",
"shasum": ""
},
"require": {
"ext-json": "*",
"illuminate/console": "^11.0|^12.0",
"illuminate/database": "^11.0|^12.0",
"illuminate/filesystem": "^11.0|^12.0",
"php": "^8.2"
},
"require-dev": {
"mockery/mockery": "^1.5.1",
"orchestra/testbench": "^9.0|^10.0",
"phpunit/phpunit": "^11.0"
},
"type": "package",
"extra": {
"laravel": {
"providers": [
"OwenIt\\Auditing\\AuditingServiceProvider"
]
},
"branch-alias": {
"dev-master": "v14-dev"
}
},
"autoload": {
"psr-4": {
"OwenIt\\Auditing\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Antério Vieira",
"email": "anteriovieira@gmail.com"
},
{
"name": "Raphael França",
"email": "raphaelfrancabsb@gmail.com"
},
{
"name": "Morten D. Hansen",
"email": "morten@visia.dk"
}
],
"description": "Audit changes of your Eloquent models in Laravel",
"homepage": "https://laravel-auditing.com",
"keywords": [
"Accountability",
"Audit",
"auditing",
"changes",
"eloquent",
"history",
"laravel",
"log",
"logging",
"lumen",
"observer",
"record",
"revision",
"tracking"
],
"support": {
"issues": "https://github.com/owen-it/laravel-auditing/issues",
"source": "https://github.com/owen-it/laravel-auditing"
},
"time": "2025-02-26T16:40:54+00:00"
},
{
"name": "phpoption/phpoption",
"version": "1.9.5",
@@ -4711,6 +4858,70 @@
],
"time": "2025-02-25T09:09:36+00:00"
},
{
"name": "spatie/backtrace",
"version": "1.8.1",
"source": {
"type": "git",
"url": "https://github.com/spatie/backtrace.git",
"reference": "8c0f16a59ae35ec8c62d85c3c17585158f430110"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/spatie/backtrace/zipball/8c0f16a59ae35ec8c62d85c3c17585158f430110",
"reference": "8c0f16a59ae35ec8c62d85c3c17585158f430110",
"shasum": ""
},
"require": {
"php": "^7.3 || ^8.0"
},
"require-dev": {
"ext-json": "*",
"laravel/serializable-closure": "^1.3 || ^2.0",
"phpunit/phpunit": "^9.3 || ^11.4.3",
"spatie/phpunit-snapshot-assertions": "^4.2 || ^5.1.6",
"symfony/var-dumper": "^5.1 || ^6.0 || ^7.0"
},
"type": "library",
"autoload": {
"psr-4": {
"Spatie\\Backtrace\\": "src"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Freek Van de Herten",
"email": "freek@spatie.be",
"homepage": "https://spatie.be",
"role": "Developer"
}
],
"description": "A better backtrace",
"homepage": "https://github.com/spatie/backtrace",
"keywords": [
"Backtrace",
"spatie"
],
"support": {
"issues": "https://github.com/spatie/backtrace/issues",
"source": "https://github.com/spatie/backtrace/tree/1.8.1"
},
"funding": [
{
"url": "https://github.com/sponsors/spatie",
"type": "github"
},
{
"url": "https://spatie.be/open-source/support-us",
"type": "other"
}
],
"time": "2025-08-26T08:22:30+00:00"
},
{
"name": "spatie/color",
"version": "1.8.0",
@@ -4770,6 +4981,232 @@
],
"time": "2025-02-10T09:22:41+00:00"
},
{
"name": "spatie/error-solutions",
"version": "1.1.3",
"source": {
"type": "git",
"url": "https://github.com/spatie/error-solutions.git",
"reference": "e495d7178ca524f2dd0fe6a1d99a1e608e1c9936"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/spatie/error-solutions/zipball/e495d7178ca524f2dd0fe6a1d99a1e608e1c9936",
"reference": "e495d7178ca524f2dd0fe6a1d99a1e608e1c9936",
"shasum": ""
},
"require": {
"php": "^8.0"
},
"require-dev": {
"illuminate/broadcasting": "^10.0|^11.0|^12.0",
"illuminate/cache": "^10.0|^11.0|^12.0",
"illuminate/support": "^10.0|^11.0|^12.0",
"livewire/livewire": "^2.11|^3.5.20",
"openai-php/client": "^0.10.1",
"orchestra/testbench": "8.22.3|^9.0|^10.0",
"pestphp/pest": "^2.20|^3.0",
"phpstan/phpstan": "^2.1",
"psr/simple-cache": "^3.0",
"psr/simple-cache-implementation": "^3.0",
"spatie/ray": "^1.28",
"symfony/cache": "^5.4|^6.0|^7.0",
"symfony/process": "^5.4|^6.0|^7.0",
"vlucas/phpdotenv": "^5.5"
},
"suggest": {
"openai-php/client": "Require get solutions from OpenAI",
"simple-cache-implementation": "To cache solutions from OpenAI"
},
"type": "library",
"autoload": {
"psr-4": {
"Spatie\\Ignition\\": "legacy/ignition",
"Spatie\\ErrorSolutions\\": "src",
"Spatie\\LaravelIgnition\\": "legacy/laravel-ignition"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Ruben Van Assche",
"email": "ruben@spatie.be",
"role": "Developer"
}
],
"description": "This is my package error-solutions",
"homepage": "https://github.com/spatie/error-solutions",
"keywords": [
"error-solutions",
"spatie"
],
"support": {
"issues": "https://github.com/spatie/error-solutions/issues",
"source": "https://github.com/spatie/error-solutions/tree/1.1.3"
},
"funding": [
{
"url": "https://github.com/Spatie",
"type": "github"
}
],
"time": "2025-02-14T12:29:50+00:00"
},
{
"name": "spatie/flare-client-php",
"version": "1.10.1",
"source": {
"type": "git",
"url": "https://github.com/spatie/flare-client-php.git",
"reference": "bf1716eb98bd689451b071548ae9e70738dce62f"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/spatie/flare-client-php/zipball/bf1716eb98bd689451b071548ae9e70738dce62f",
"reference": "bf1716eb98bd689451b071548ae9e70738dce62f",
"shasum": ""
},
"require": {
"illuminate/pipeline": "^8.0|^9.0|^10.0|^11.0|^12.0",
"php": "^8.0",
"spatie/backtrace": "^1.6.1",
"symfony/http-foundation": "^5.2|^6.0|^7.0",
"symfony/mime": "^5.2|^6.0|^7.0",
"symfony/process": "^5.2|^6.0|^7.0",
"symfony/var-dumper": "^5.2|^6.0|^7.0"
},
"require-dev": {
"dms/phpunit-arraysubset-asserts": "^0.5.0",
"pestphp/pest": "^1.20|^2.0",
"phpstan/extension-installer": "^1.1",
"phpstan/phpstan-deprecation-rules": "^1.0",
"phpstan/phpstan-phpunit": "^1.0",
"spatie/pest-plugin-snapshots": "^1.0|^2.0"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-main": "1.3.x-dev"
}
},
"autoload": {
"files": [
"src/helpers.php"
],
"psr-4": {
"Spatie\\FlareClient\\": "src"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"description": "Send PHP errors to Flare",
"homepage": "https://github.com/spatie/flare-client-php",
"keywords": [
"exception",
"flare",
"reporting",
"spatie"
],
"support": {
"issues": "https://github.com/spatie/flare-client-php/issues",
"source": "https://github.com/spatie/flare-client-php/tree/1.10.1"
},
"funding": [
{
"url": "https://github.com/spatie",
"type": "github"
}
],
"time": "2025-02-14T13:42:06+00:00"
},
{
"name": "spatie/ignition",
"version": "1.15.1",
"source": {
"type": "git",
"url": "https://github.com/spatie/ignition.git",
"reference": "31f314153020aee5af3537e507fef892ffbf8c85"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/spatie/ignition/zipball/31f314153020aee5af3537e507fef892ffbf8c85",
"reference": "31f314153020aee5af3537e507fef892ffbf8c85",
"shasum": ""
},
"require": {
"ext-json": "*",
"ext-mbstring": "*",
"php": "^8.0",
"spatie/error-solutions": "^1.0",
"spatie/flare-client-php": "^1.7",
"symfony/console": "^5.4|^6.0|^7.0",
"symfony/var-dumper": "^5.4|^6.0|^7.0"
},
"require-dev": {
"illuminate/cache": "^9.52|^10.0|^11.0|^12.0",
"mockery/mockery": "^1.4",
"pestphp/pest": "^1.20|^2.0",
"phpstan/extension-installer": "^1.1",
"phpstan/phpstan-deprecation-rules": "^1.0",
"phpstan/phpstan-phpunit": "^1.0",
"psr/simple-cache-implementation": "*",
"symfony/cache": "^5.4|^6.0|^7.0",
"symfony/process": "^5.4|^6.0|^7.0",
"vlucas/phpdotenv": "^5.5"
},
"suggest": {
"openai-php/client": "Require get solutions from OpenAI",
"simple-cache-implementation": "To cache solutions from OpenAI"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-main": "1.5.x-dev"
}
},
"autoload": {
"psr-4": {
"Spatie\\Ignition\\": "src"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Spatie",
"email": "info@spatie.be",
"role": "Developer"
}
],
"description": "A beautiful error page for PHP applications.",
"homepage": "https://flareapp.io/ignition",
"keywords": [
"error",
"flare",
"laravel",
"page"
],
"support": {
"docs": "https://flareapp.io/docs/ignition-for-laravel/introduction",
"forum": "https://twitter.com/flareappio",
"issues": "https://github.com/spatie/ignition/issues",
"source": "https://github.com/spatie/ignition"
},
"funding": [
{
"url": "https://github.com/spatie",
"type": "github"
}
],
"time": "2025-02-21T14:31:39+00:00"
},
{
"name": "spatie/invade",
"version": "2.1.0",
@@ -4829,6 +5266,98 @@
],
"time": "2024-05-17T09:06:10+00:00"
},
{
"name": "spatie/laravel-ignition",
"version": "2.11.0",
"source": {
"type": "git",
"url": "https://github.com/spatie/laravel-ignition.git",
"reference": "11f38d1ff7abc583a61c96bf3c1b03610a69cccd"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/spatie/laravel-ignition/zipball/11f38d1ff7abc583a61c96bf3c1b03610a69cccd",
"reference": "11f38d1ff7abc583a61c96bf3c1b03610a69cccd",
"shasum": ""
},
"require": {
"ext-curl": "*",
"ext-json": "*",
"ext-mbstring": "*",
"illuminate/support": "^11.0|^12.0|^13.0",
"nesbot/carbon": "^2.72|^3.0",
"php": "^8.2",
"spatie/ignition": "^1.15.1",
"symfony/console": "^7.4|^8.0",
"symfony/var-dumper": "^7.4|^8.0"
},
"require-dev": {
"livewire/livewire": "^3.7.0|^4.0|dev-josh/v3-laravel-13-support",
"mockery/mockery": "^1.6.12",
"openai-php/client": "^0.10.3|^0.19",
"orchestra/testbench": "^v9.16.0|^10.6|^11.0",
"pestphp/pest": "^3.7|^4.0",
"phpstan/extension-installer": "^1.4.3",
"phpstan/phpstan-deprecation-rules": "^2.0.3",
"phpstan/phpstan-phpunit": "^2.0.8",
"vlucas/phpdotenv": "^5.6.2"
},
"suggest": {
"openai-php/client": "Require get solutions from OpenAI",
"psr/simple-cache-implementation": "Needed to cache solutions from OpenAI"
},
"type": "library",
"extra": {
"laravel": {
"aliases": {
"Flare": "Spatie\\LaravelIgnition\\Facades\\Flare"
},
"providers": [
"Spatie\\LaravelIgnition\\IgnitionServiceProvider"
]
}
},
"autoload": {
"files": [
"src/helpers.php"
],
"psr-4": {
"Spatie\\LaravelIgnition\\": "src"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Spatie",
"email": "info@spatie.be",
"role": "Developer"
}
],
"description": "A beautiful error page for Laravel applications.",
"homepage": "https://flareapp.io/ignition",
"keywords": [
"error",
"flare",
"laravel",
"page"
],
"support": {
"docs": "https://flareapp.io/docs/ignition-for-laravel/introduction",
"forum": "https://twitter.com/flareappio",
"issues": "https://github.com/spatie/laravel-ignition/issues",
"source": "https://github.com/spatie/laravel-ignition"
},
"funding": [
{
"url": "https://github.com/spatie",
"type": "github"
}
],
"time": "2026-02-22T19:14:05+00:00"
},
{
"name": "spatie/laravel-package-tools",
"version": "1.93.0",
@@ -4890,6 +5419,89 @@
],
"time": "2026-02-21T12:49:54+00:00"
},
{
"name": "spatie/laravel-permission",
"version": "6.24.1",
"source": {
"type": "git",
"url": "https://github.com/spatie/laravel-permission.git",
"reference": "eefc9d17eba80d023d6bff313f882cb2bcd691a3"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/spatie/laravel-permission/zipball/eefc9d17eba80d023d6bff313f882cb2bcd691a3",
"reference": "eefc9d17eba80d023d6bff313f882cb2bcd691a3",
"shasum": ""
},
"require": {
"illuminate/auth": "^8.12|^9.0|^10.0|^11.0|^12.0",
"illuminate/container": "^8.12|^9.0|^10.0|^11.0|^12.0",
"illuminate/contracts": "^8.12|^9.0|^10.0|^11.0|^12.0",
"illuminate/database": "^8.12|^9.0|^10.0|^11.0|^12.0",
"php": "^8.0"
},
"require-dev": {
"laravel/passport": "^11.0|^12.0",
"laravel/pint": "^1.0",
"orchestra/testbench": "^6.23|^7.0|^8.0|^9.0|^10.0",
"phpunit/phpunit": "^9.4|^10.1|^11.5"
},
"type": "library",
"extra": {
"laravel": {
"providers": [
"Spatie\\Permission\\PermissionServiceProvider"
]
},
"branch-alias": {
"dev-main": "6.x-dev",
"dev-master": "6.x-dev"
}
},
"autoload": {
"files": [
"src/helpers.php"
],
"psr-4": {
"Spatie\\Permission\\": "src"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Freek Van der Herten",
"email": "freek@spatie.be",
"homepage": "https://spatie.be",
"role": "Developer"
}
],
"description": "Permission handling for Laravel 8.0 and up",
"homepage": "https://github.com/spatie/laravel-permission",
"keywords": [
"acl",
"laravel",
"permission",
"permissions",
"rbac",
"roles",
"security",
"spatie"
],
"support": {
"issues": "https://github.com/spatie/laravel-permission/issues",
"source": "https://github.com/spatie/laravel-permission/tree/6.24.1"
},
"funding": [
{
"url": "https://github.com/spatie",
"type": "github"
}
],
"time": "2026-02-09T21:10:03+00:00"
},
{
"name": "symfony/clock",
"version": "v7.4.0",

202
src/config/permission.php Normal file
View File

@@ -0,0 +1,202 @@
<?php
return [
'models' => [
/*
* When using the "HasPermissions" trait from this package, we need to know which
* Eloquent model should be used to retrieve your permissions. Of course, it
* is often just the "Permission" model but you may use whatever you like.
*
* The model you want to use as a Permission model needs to implement the
* `Spatie\Permission\Contracts\Permission` contract.
*/
'permission' => Spatie\Permission\Models\Permission::class,
/*
* When using the "HasRoles" trait from this package, we need to know which
* Eloquent model should be used to retrieve your roles. Of course, it
* is often just the "Role" model but you may use whatever you like.
*
* The model you want to use as a Role model needs to implement the
* `Spatie\Permission\Contracts\Role` contract.
*/
'role' => Spatie\Permission\Models\Role::class,
],
'table_names' => [
/*
* When using the "HasRoles" trait from this package, we need to know which
* table should be used to retrieve your roles. We have chosen a basic
* default value but you may easily change it to any table you like.
*/
'roles' => 'roles',
/*
* When using the "HasPermissions" trait from this package, we need to know which
* table should be used to retrieve your permissions. We have chosen a basic
* default value but you may easily change it to any table you like.
*/
'permissions' => 'permissions',
/*
* When using the "HasPermissions" trait from this package, we need to know which
* table should be used to retrieve your models permissions. We have chosen a
* basic default value but you may easily change it to any table you like.
*/
'model_has_permissions' => 'model_has_permissions',
/*
* When using the "HasRoles" trait from this package, we need to know which
* table should be used to retrieve your models roles. We have chosen a
* basic default value but you may easily change it to any table you like.
*/
'model_has_roles' => 'model_has_roles',
/*
* When using the "HasRoles" trait from this package, we need to know which
* table should be used to retrieve your roles permissions. We have chosen a
* basic default value but you may easily change it to any table you like.
*/
'role_has_permissions' => 'role_has_permissions',
],
'column_names' => [
/*
* Change this if you want to name the related pivots other than defaults
*/
'role_pivot_key' => null, // default 'role_id',
'permission_pivot_key' => null, // default 'permission_id',
/*
* Change this if you want to name the related model primary key other than
* `model_id`.
*
* For example, this would be nice if your primary keys are all UUIDs. In
* that case, name this `model_uuid`.
*/
'model_morph_key' => 'model_id',
/*
* Change this if you want to use the teams feature and your related model's
* foreign key is other than `team_id`.
*/
'team_foreign_key' => 'team_id',
],
/*
* When set to true, the method for checking permissions will be registered on the gate.
* Set this to false if you want to implement custom logic for checking permissions.
*/
'register_permission_check_method' => true,
/*
* When set to true, Laravel\Octane\Events\OperationTerminated event listener will be registered
* this will refresh permissions on every TickTerminated, TaskTerminated and RequestTerminated
* NOTE: This should not be needed in most cases, but an Octane/Vapor combination benefited from it.
*/
'register_octane_reset_listener' => false,
/*
* Events will fire when a role or permission is assigned/unassigned:
* \Spatie\Permission\Events\RoleAttached
* \Spatie\Permission\Events\RoleDetached
* \Spatie\Permission\Events\PermissionAttached
* \Spatie\Permission\Events\PermissionDetached
*
* To enable, set to true, and then create listeners to watch these events.
*/
'events_enabled' => false,
/*
* Teams Feature.
* When set to true the package implements teams using the 'team_foreign_key'.
* If you want the migrations to register the 'team_foreign_key', you must
* set this to true before doing the migration.
* If you already did the migration then you must make a new migration to also
* add 'team_foreign_key' to 'roles', 'model_has_roles', and 'model_has_permissions'
* (view the latest version of this package's migration file)
*/
'teams' => false,
/*
* The class to use to resolve the permissions team id
*/
'team_resolver' => \Spatie\Permission\DefaultTeamResolver::class,
/*
* Passport Client Credentials Grant
* When set to true the package will use Passports Client to check permissions
*/
'use_passport_client_credentials' => false,
/*
* When set to true, the required permission names are added to exception messages.
* This could be considered an information leak in some contexts, so the default
* setting is false here for optimum safety.
*/
'display_permission_in_exception' => false,
/*
* When set to true, the required role names are added to exception messages.
* This could be considered an information leak in some contexts, so the default
* setting is false here for optimum safety.
*/
'display_role_in_exception' => false,
/*
* By default wildcard permission lookups are disabled.
* See documentation to understand supported syntax.
*/
'enable_wildcard_permission' => false,
/*
* The class to use for interpreting wildcard permissions.
* If you need to modify delimiters, override the class and specify its name here.
*/
// 'wildcard_permission' => Spatie\Permission\WildcardPermission::class,
/* Cache-specific settings */
'cache' => [
/*
* By default all permissions are cached for 24 hours to speed up performance.
* When permissions or roles are updated the cache is flushed automatically.
*/
'expiration_time' => \DateInterval::createFromDateString('24 hours'),
/*
* The cache key used to store all permissions.
*/
'key' => 'spatie.permission.cache',
/*
* You may optionally indicate a specific cache driver to use for permission and
* role caching using any of the `store` drivers listed in the cache.php config
* file. Using 'default' here means to use the `default` set in cache.php.
*/
'store' => 'default',
],
];

84
src/config/sanctum.php Normal file
View File

@@ -0,0 +1,84 @@
<?php
use Laravel\Sanctum\Sanctum;
return [
/*
|--------------------------------------------------------------------------
| Stateful Domains
|--------------------------------------------------------------------------
|
| Requests from the following domains / hosts will receive stateful API
| authentication cookies. Typically, these should include your local
| and production domains which access your API via a frontend SPA.
|
*/
'stateful' => explode(',', env('SANCTUM_STATEFUL_DOMAINS', sprintf(
'%s%s',
'localhost,localhost:3000,127.0.0.1,127.0.0.1:8000,::1',
Sanctum::currentApplicationUrlWithPort(),
// Sanctum::currentRequestHost(),
))),
/*
|--------------------------------------------------------------------------
| Sanctum Guards
|--------------------------------------------------------------------------
|
| This array contains the authentication guards that will be checked when
| Sanctum is trying to authenticate a request. If none of these guards
| are able to authenticate the request, Sanctum will use the bearer
| token that's present on an incoming request for authentication.
|
*/
'guard' => ['web'],
/*
|--------------------------------------------------------------------------
| Expiration Minutes
|--------------------------------------------------------------------------
|
| This value controls the number of minutes until an issued token will be
| considered expired. This will override any values set in the token's
| "expires_at" attribute, but first-party sessions are not affected.
|
*/
'expiration' => null,
/*
|--------------------------------------------------------------------------
| Token Prefix
|--------------------------------------------------------------------------
|
| Sanctum can prefix new tokens in order to take advantage of numerous
| security scanning initiatives maintained by open source platforms
| that notify developers if they commit tokens into repositories.
|
| See: https://docs.github.com/en/code-security/secret-scanning/about-secret-scanning
|
*/
'token_prefix' => env('SANCTUM_TOKEN_PREFIX', ''),
/*
|--------------------------------------------------------------------------
| Sanctum Middleware
|--------------------------------------------------------------------------
|
| When authenticating your first-party SPA with Sanctum you may need to
| customize some of the middleware Sanctum uses while processing the
| request. You may change the middleware listed below as required.
|
*/
'middleware' => [
'authenticate_session' => Laravel\Sanctum\Http\Middleware\AuthenticateSession::class,
'encrypt_cookies' => Illuminate\Cookie\Middleware\EncryptCookies::class,
'validate_csrf_token' => Illuminate\Foundation\Http\Middleware\ValidateCsrfToken::class,
],
];

View File

@@ -0,0 +1,30 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('settings', function (Blueprint $table) {
$table->id();
$table->string('key')->unique();
$table->text('value')->nullable();
$table->string('type')->default('string');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('settings');
}
};

View File

@@ -0,0 +1,134 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
$teams = config('permission.teams');
$tableNames = config('permission.table_names');
$columnNames = config('permission.column_names');
$pivotRole = $columnNames['role_pivot_key'] ?? 'role_id';
$pivotPermission = $columnNames['permission_pivot_key'] ?? 'permission_id';
throw_if(empty($tableNames), Exception::class, 'Error: config/permission.php not loaded. Run [php artisan config:clear] and try again.');
throw_if($teams && empty($columnNames['team_foreign_key'] ?? null), Exception::class, 'Error: team_foreign_key on config/permission.php not loaded. Run [php artisan config:clear] and try again.');
Schema::create($tableNames['permissions'], static function (Blueprint $table) {
// $table->engine('InnoDB');
$table->bigIncrements('id'); // permission id
$table->string('name'); // For MyISAM use string('name', 225); // (or 166 for InnoDB with Redundant/Compact row format)
$table->string('guard_name'); // For MyISAM use string('guard_name', 25);
$table->timestamps();
$table->unique(['name', 'guard_name']);
});
Schema::create($tableNames['roles'], static function (Blueprint $table) use ($teams, $columnNames) {
// $table->engine('InnoDB');
$table->bigIncrements('id'); // role id
if ($teams || config('permission.testing')) { // permission.testing is a fix for sqlite testing
$table->unsignedBigInteger($columnNames['team_foreign_key'])->nullable();
$table->index($columnNames['team_foreign_key'], 'roles_team_foreign_key_index');
}
$table->string('name'); // For MyISAM use string('name', 225); // (or 166 for InnoDB with Redundant/Compact row format)
$table->string('guard_name'); // For MyISAM use string('guard_name', 25);
$table->timestamps();
if ($teams || config('permission.testing')) {
$table->unique([$columnNames['team_foreign_key'], 'name', 'guard_name']);
} else {
$table->unique(['name', 'guard_name']);
}
});
Schema::create($tableNames['model_has_permissions'], static function (Blueprint $table) use ($tableNames, $columnNames, $pivotPermission, $teams) {
$table->unsignedBigInteger($pivotPermission);
$table->string('model_type');
$table->unsignedBigInteger($columnNames['model_morph_key']);
$table->index([$columnNames['model_morph_key'], 'model_type'], 'model_has_permissions_model_id_model_type_index');
$table->foreign($pivotPermission)
->references('id') // permission id
->on($tableNames['permissions'])
->onDelete('cascade');
if ($teams) {
$table->unsignedBigInteger($columnNames['team_foreign_key']);
$table->index($columnNames['team_foreign_key'], 'model_has_permissions_team_foreign_key_index');
$table->primary([$columnNames['team_foreign_key'], $pivotPermission, $columnNames['model_morph_key'], 'model_type'],
'model_has_permissions_permission_model_type_primary');
} else {
$table->primary([$pivotPermission, $columnNames['model_morph_key'], 'model_type'],
'model_has_permissions_permission_model_type_primary');
}
});
Schema::create($tableNames['model_has_roles'], static function (Blueprint $table) use ($tableNames, $columnNames, $pivotRole, $teams) {
$table->unsignedBigInteger($pivotRole);
$table->string('model_type');
$table->unsignedBigInteger($columnNames['model_morph_key']);
$table->index([$columnNames['model_morph_key'], 'model_type'], 'model_has_roles_model_id_model_type_index');
$table->foreign($pivotRole)
->references('id') // role id
->on($tableNames['roles'])
->onDelete('cascade');
if ($teams) {
$table->unsignedBigInteger($columnNames['team_foreign_key']);
$table->index($columnNames['team_foreign_key'], 'model_has_roles_team_foreign_key_index');
$table->primary([$columnNames['team_foreign_key'], $pivotRole, $columnNames['model_morph_key'], 'model_type'],
'model_has_roles_role_model_type_primary');
} else {
$table->primary([$pivotRole, $columnNames['model_morph_key'], 'model_type'],
'model_has_roles_role_model_type_primary');
}
});
Schema::create($tableNames['role_has_permissions'], static function (Blueprint $table) use ($tableNames, $pivotRole, $pivotPermission) {
$table->unsignedBigInteger($pivotPermission);
$table->unsignedBigInteger($pivotRole);
$table->foreign($pivotPermission)
->references('id') // permission id
->on($tableNames['permissions'])
->onDelete('cascade');
$table->foreign($pivotRole)
->references('id') // role id
->on($tableNames['roles'])
->onDelete('cascade');
$table->primary([$pivotPermission, $pivotRole], 'role_has_permissions_permission_id_role_id_primary');
});
app('cache')
->store(config('permission.cache.store') != 'default' ? config('permission.cache.store') : null)
->forget(config('permission.cache.key'));
}
/**
* Reverse the migrations.
*/
public function down(): void
{
$tableNames = config('permission.table_names');
throw_if(empty($tableNames), Exception::class, 'Error: config/permission.php not found and defaults could not be merged. Please publish the package configuration before proceeding, or drop the tables manually.');
Schema::drop($tableNames['role_has_permissions']);
Schema::drop($tableNames['model_has_roles']);
Schema::drop($tableNames['model_has_permissions']);
Schema::drop($tableNames['roles']);
Schema::drop($tableNames['permissions']);
}
};

View File

@@ -0,0 +1,27 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('audits', function (Blueprint $table) {
$table->id();
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('audits');
}
};

View File

@@ -0,0 +1,33 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('personal_access_tokens', function (Blueprint $table) {
$table->id();
$table->morphs('tokenable');
$table->text('name');
$table->string('token', 64)->unique();
$table->text('abilities')->nullable();
$table->timestamp('last_used_at')->nullable();
$table->timestamp('expires_at')->nullable()->index();
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('personal_access_tokens');
}
};

View File

@@ -0,0 +1,42 @@
<?php
namespace Database\Seeders;
use Illuminate\Database\Seeder;
use Spatie\Permission\Models\Role;
use Spatie\Permission\Models\Permission;
use App\Models\User;
class RolePermissionSeeder extends Seeder
{
public function run(): void
{
app()[\Spatie\Permission\PermissionRegistrar::class]->forgetCachedPermissions();
$permissions = [
'users.view',
'users.create',
'users.edit',
'users.delete',
'settings.manage',
];
foreach ($permissions as $permission) {
Permission::create(['name' => $permission]);
}
$adminRole = Role::create(['name' => 'admin']);
$adminRole->givePermissionTo(Permission::all());
$editorRole = Role::create(['name' => 'editor']);
$editorRole->givePermissionTo(['users.view', 'users.edit']);
$viewerRole = Role::create(['name' => 'viewer']);
$viewerRole->givePermissionTo(['users.view']);
$admin = User::where('email', 'admin@example.com')->first();
if ($admin) {
$admin->assignRole('admin');
}
}
}

View File

@@ -0,0 +1,9 @@
<x-filament-panels::page>
<form wire:submit="save">
{{ $this->form }}
<x-filament-panels::form.actions
:actions="$this->getFormActions()"
/>
</form>
</x-filament-panels::page>

View File

@@ -0,0 +1,3 @@
<x-filament-panels::page>
</x-filament-panels::page>

8
src/routes/api.php Normal file
View File

@@ -0,0 +1,8 @@
<?php
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Route;
Route::get('/user', function (Request $request) {
return $request->user();
})->middleware('auth:sanctum');