Seiten: Unterseiten anlegen als eigenes Recht (0.25.2)
Some checks failed
CI / PHP 8.3 / mariadb:10.6 (pull_request) Successful in 5m14s
CI / PHP 8.4 / mariadb:10.6 (pull_request) Successful in 5m4s
CI / PHP 8.3 / mariadb:11.4 (pull_request) Successful in 4m58s
CI / PHP 8.4 / mariadb:11.4 (pull_request) Successful in 5m0s
CI / PHP 8.3 / mysql:8.0 (pull_request) Failing after 7m38s
CI / PHP 8.4 / mysql:8.0 (pull_request) Failing after 7m28s
CI / PHP 8.3 / mysql:8.4 (pull_request) Failing after 5m54s
CI / PHP 8.4 / mysql:8.4 (pull_request) Failing after 5m49s
CI / Build-Artefakte aktuell (pull_request) Successful in 1m51s

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Friederich Loheide 2026-09-27 09:24:13 +00:00
parent 84a9815150
commit fbee65f948
8 changed files with 85 additions and 8 deletions

View file

@ -0,0 +1,41 @@
<?php
use App\Support\Permissions\Permissions;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Support\Facades\DB;
/**
* „Unterseiten anlegen“ ist jetzt ein eigenes Recht. Bisher durfte das jede Rolle mit
* „Seiten bearbeiten“ – damit sich nichts ändert, bekommen diese Rollen das neue Recht dazu.
*/
return new class extends Migration
{
public function up(): void
{
$now = now();
DB::table('grants')->where('ability', 'pages.edit')->orderBy('id')->get()->each(function ($grant) use ($now) {
$exists = DB::table('grants')->where('role_id', $grant->role_id)->where('ability', 'pages.create')
->where('resource_type', $grant->resource_type)->where('resource_id', $grant->resource_id)->exists();
if (! $exists) {
DB::table('grants')->insert([
'role_id' => $grant->role_id,
'ability' => 'pages.create',
'resource_type' => $grant->resource_type,
'resource_id' => $grant->resource_id,
'include_children' => $grant->include_children,
'created_at' => $now,
'updated_at' => $now,
]);
}
});
Permissions::flush();
}
public function down(): void
{
DB::table('grants')->where('ability', 'pages.create')->delete();
}
};