Snapshot of main at 9f39a6e1e (2026-11-02)
This commit is contained in:
commit
6ccf1792d7
2580 files changed
+1040202
No files matched your search
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
// Run with: php artisan tinker --execute="require base_path('fix_content_manager.php');"
|
||||
// Delete this file after use.
|
||||
|
||||
// For every Admin profile, ensure all AdminRole scoped Spatie roles exist and have correct permissions.
|
||||
|
||||
$adminRoles = \App\Models\AdminRole::all();
|
||||
$admins = \App\Models\Admin::all();
|
||||
|
||||
foreach ($admins as $admin) {
|
||||
echo "Admin #{$admin->id}: {$admin->name}\n";
|
||||
|
||||
foreach ($adminRoles as $adminRole) {
|
||||
$scopedName = 'Admin\\' . $admin->id . '\\' . $adminRole->name;
|
||||
|
||||
$spatieRole = \Spatie\Permission\Models\Role::firstOrCreate(
|
||||
['name' => $scopedName, 'guard_name' => 'web']
|
||||
);
|
||||
|
||||
$wasCreated = $spatieRole->wasRecentlyCreated;
|
||||
$spatieRole->syncPermissions($adminRole->permissions ?? []);
|
||||
|
||||
echo ' ' . ($wasCreated ? '[CREATED] ' : '[synced] ') . $scopedName . "\n";
|
||||
}
|
||||
}
|
||||
|
||||
app()[\Spatie\Permission\PermissionRegistrar::class]->forgetCachedPermissions();
|
||||
echo "\nAll scoped roles ensured and permissions synced. Cache cleared.\n";
|
||||
Reference in new issue
Block a user