0
0
Fork 0
mirror of https://github.com/BookStackApp/BookStack.git synced 2025-05-11 19:35:37 +00:00

Started implementation of page template

This commit is contained in:
Dan Brown 2019-07-07 13:45:46 +01:00
parent f7f7cd464c
commit 71167426bb
No known key found for this signature in database
GPG key ID: 46D9F943C24A2EF9
14 changed files with 273 additions and 125 deletions

View file

@ -0,0 +1,54 @@
<?php
use Carbon\Carbon;
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class AddTemplateSupport extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('pages', function (Blueprint $table) {
$table->boolean('template')->default(false);
$table->index('template');
});
// Create new templates-manage permission and assign to admin role
$adminRoleId = DB::table('roles')->where('system_name', '=', 'admin')->first()->id;
$permissionId = DB::table('role_permissions')->insertGetId([
'name' => 'templates-manage',
'display_name' => 'Manage Page Templates',
'created_at' => Carbon::now()->toDateTimeString(),
'updated_at' => Carbon::now()->toDateTimeString()
]);
DB::table('permission_role')->insert([
'role_id' => $adminRoleId,
'permission_id' => $permissionId
]);
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('pages', function (Blueprint $table) {
$table->dropColumn('template');
});
// Remove templates-manage permission
$templatesManagePermission = DB::table('role_permissions')
->where('name', '=', 'templates_manage')->first();
DB::table('permission_role')->where('permission_id', '=', $templatesManagePermission->id)->delete();
DB::table('role_permissions')->where('name', '=', 'templates_manage')->delete();
}
}