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:
parent
f7f7cd464c
commit
71167426bb
14 changed files with 273 additions and 125 deletions
database/migrations
|
@ -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();
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue