feat(mailbox): Implement cinematic UX and user tiers
- Added Spatie roles (free, pro, enterprise, admin) and access scopes - Implemented delayed, cinematic mailbox provisioning animation - Fixed GSAP and SVG collision issues on creation overlay - Improved component sync with livewire refresh - Added feature tests for tier systems and fixed RegistrationTest
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Illuminate\Support\Str;
|
||||
@@ -41,4 +42,24 @@ class UserFactory extends Factory
|
||||
'email_verified_at' => null,
|
||||
]);
|
||||
}
|
||||
|
||||
public function free(): static
|
||||
{
|
||||
return $this->afterCreating(fn (User $user) => $user->assignRole('free'));
|
||||
}
|
||||
|
||||
public function pro(): static
|
||||
{
|
||||
return $this->afterCreating(fn (User $user) => $user->assignRole('pro'));
|
||||
}
|
||||
|
||||
public function enterprise(): static
|
||||
{
|
||||
return $this->afterCreating(fn (User $user) => $user->assignRole('enterprise'));
|
||||
}
|
||||
|
||||
public function admin(): static
|
||||
{
|
||||
return $this->afterCreating(fn (User $user) => $user->assignRole('admin'));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Seeder;
|
||||
use Spatie\Permission\Models\Permission;
|
||||
use Spatie\Permission\Models\Role;
|
||||
@@ -14,13 +14,30 @@ class RoleSeeder extends Seeder
|
||||
*/
|
||||
public function run(): void
|
||||
{
|
||||
$role = Role::findOrCreate(name: 'admin', guardName: 'web');
|
||||
Role::findOrCreate(name: 'user', guardName: 'web');
|
||||
// Clear Spatie's permission cache before seeding
|
||||
app()[\Spatie\Permission\PermissionRegistrar::class]->forgetCachedPermissions();
|
||||
|
||||
$permissionManageMails = Permission::findOrCreate(name: 'manage mails', guardName: 'web');
|
||||
$role->givePermissionTo($permissionManageMails);
|
||||
// --- Create Tier Roles ---
|
||||
$admin = Role::findOrCreate('admin', 'web');
|
||||
Role::findOrCreate('free', 'web');
|
||||
Role::findOrCreate('pro', 'web');
|
||||
Role::findOrCreate('enterprise', 'web');
|
||||
|
||||
$permissionManageFilamentPanel = Permission::findOrCreate(name: 'manage panels', guardName: 'web');
|
||||
$role->givePermissionTo($permissionManageFilamentPanel);
|
||||
// --- Permissions (admin-only) ---
|
||||
$manageMailsPerm = Permission::findOrCreate('manage mails', 'web');
|
||||
$managePanelsPerm = Permission::findOrCreate('manage panels', 'web');
|
||||
$admin->syncPermissions([$manageMailsPerm, $managePanelsPerm]);
|
||||
|
||||
// --- Migrate legacy 'user' role to 'free' ---
|
||||
$legacyRole = Role::where('name', 'user')->where('guard_name', 'web')->first();
|
||||
if ($legacyRole) {
|
||||
// Move all users with 'user' role to 'free'
|
||||
$usersWithLegacyRole = \App\Models\User::role('user')->get();
|
||||
foreach ($usersWithLegacyRole as $user) {
|
||||
$user->removeRole('user');
|
||||
$user->assignRole('free');
|
||||
}
|
||||
$legacyRole->delete();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user