/** * Run the database seeds. * * @return void */ public function run() { $application = Application::create(['name' => 'Soda']); $application_url = ApplicationUrl::create(['application_id' => $application->id, 'domain' => 'soda.dev', 'folder' => '']); $user = User::create(['name' => 'admin', 'email' => '*****@*****.**', 'password' => \Hash::make('password')]); $role_global_admin = Role::create(['name' => 'global_admin', 'display_name' => 'Global Administrator', 'description' => 'User is the administrator of all applications', 'application_id' => $application->id]); $role_admin = Role::create(['name' => 'admin', 'display_name' => 'Administrator', 'description' => 'User is the administrator of a given application', 'application_id' => $application->id]); $role_user = Role::create(['name' => 'user', 'display_name' => 'User', 'description' => 'Standard user (authenticated)', 'application_id' => $application->id]); $role_guest = Role::create(['name' => 'guest', 'display_name' => 'Guest', 'description' => 'Unauthenticated user', 'application_id' => $application->id]); $basic_admin = Permission::create(['name' => 'basic-admin', 'display_name' => 'Basic Admin', 'description' => 'User can access basic admin features', 'section' => 'admin', 'application_id' => $application->id]); $manage_own_permissions = Permission::create(['name' => 'manage-own-permissions', 'display_name' => 'Manage own permissions', 'description' => 'User can manage own permissions', 'section' => 'admin', 'application_id' => $application->id]); $manage_permissions = Permission::create(['name' => 'manage-permissions', 'display_name' => 'Manage permissions', 'description' => 'User can manage permissions', 'section' => 'admin', 'application_id' => $application->id]); $manage_groups = Permission::create(['name' => 'manage-roles', 'display_name' => 'Manage roles', 'description' => 'User can manage roles', 'section' => 'admin', 'application_id' => $application->id]); $manage_users = Permission::create(['name' => 'manage-users', 'display_name' => 'Manage users', 'description' => 'User can manage users', 'section' => 'admin', 'application_id' => $application->id]); $user->applications()->attach($application); $role_global_admin->attachPermission($basic_admin); $role_global_admin->attachPermission($manage_own_permissions); $role_global_admin->attachPermission($manage_permissions); $role_global_admin->attachPermission($manage_groups); $role_global_admin->attachPermission($manage_users); $role_admin->attachPermission($basic_admin); $role_admin->attachPermission($manage_own_permissions); $role_admin->attachPermission($manage_permissions); $role_admin->attachPermission($manage_groups); $role_admin->attachPermission($manage_users); $user->attachRole($role_global_admin); }
/** * Auto generated seed file * * @return void */ public function run() { $role_developer = Role::create(['name' => 'developer', 'display_name' => 'Developer', 'description' => 'Developers gain access to additional functionality']); $role_admin = Role::create(['name' => 'admin', 'display_name' => 'Admin', 'description' => 'Admins have high-level access to the CMS. Recommended for clients.']); $permission_access_cms = Permission::create(['name' => 'access-cms', 'display_name' => 'Access CMS', 'description' => 'Allow login/access to CMS.']); $permission_view_users = Permission::create(['name' => 'view-users', 'display_name' => 'View Users', 'description' => 'View list of users and their details.']); $permission_edit_users = Permission::create(['name' => 'edit-users', 'display_name' => 'Edit Users', 'description' => 'Edit user profile information.']); $permission_create_users = Permission::create(['name' => 'create-users', 'display_name' => 'Create Users', 'description' => 'Create new user accounts.']); $permission_delete_users = Permission::create(['name' => 'delete-users', 'display_name' => 'Delete Users', 'description' => 'Delete existing user accounts.']); $permission_view_pages = Permission::create(['name' => 'view-pages', 'display_name' => 'View Pages', 'description' => 'View list of pages and their contents.']); $permission_edit_pages = Permission::create(['name' => 'edit-pages', 'display_name' => 'Edit Pages', 'description' => 'Edit page content.']); $permission_create_pages = Permission::create(['name' => 'create-pages', 'display_name' => 'Create Pages', 'description' => 'Create new pages.']); $permission_delete_pages = Permission::create(['name' => 'delete-pages', 'display_name' => 'Delete Pages', 'description' => 'Delete existing pages.']); $permission_manage_page_types = Permission::create(['name' => 'manage-page-types', 'display_name' => 'Manage Page Types', 'description' => 'Manage types to build pages from.']); $permission_advanced_pages = Permission::create(['name' => 'advanced-pages', 'display_name' => 'Pages (advanced options)', 'description' => 'Access advanced page options.']); $permission_view_blocks = Permission::create(['name' => 'view-blocks', 'display_name' => 'View Blocks', 'description' => 'View list of blocks and their contents.']); $permission_edit_blocks = Permission::create(['name' => 'edit-blocks', 'display_name' => 'Edit Blocks', 'description' => 'Edit blocks content.']); $permission_create_blocks = Permission::create(['name' => 'create-blocks', 'display_name' => 'Create Blocks', 'description' => 'Create new blocks.']); $permission_delete_blocks = Permission::create(['name' => 'delete-blocks', 'display_name' => 'Delete Blocks', 'description' => 'Delete existing blocks.']); $permission_manage_block_types = Permission::create(['name' => 'manage-block-types', 'display_name' => 'Manage Block Types', 'description' => 'Manage types to build blocks from.']); $permission_advanced_blocks = Permission::create(['name' => 'advanced-blocks', 'display_name' => 'Blocks (advanced options)', 'description' => 'Access advanced block options.']); $permission_manage_fields = Permission::create(['name' => 'manage-fields', 'display_name' => 'Manage Fields', 'description' => 'Manage fields association with page/block content.']); $permission_view_drafts = Permission::create(['name' => 'view-drafts', 'display_name' => 'View Drafts', 'description' => 'View content in draft mode on the live site.']); $role_developer->attachPermissions([$permission_manage_page_types, $permission_advanced_pages, $permission_manage_block_types, $permission_advanced_blocks, $permission_manage_fields, $permission_view_drafts]); $role_admin->attachPermissions([$permission_access_cms, $permission_view_users, $permission_edit_users, $permission_create_users, $permission_delete_users, $permission_view_pages, $permission_edit_pages, $permission_create_pages, $permission_delete_pages, $permission_view_blocks, $permission_edit_blocks, $permission_create_blocks, $permission_delete_blocks]); }
/** * Auto generated seed file * * @return void */ public function run() { $developer = User::create(['username' => 'Developer', 'email' => '*****@*****.**', 'password' => Hash::make('katana12')]); $admin = User::create(['username' => 'Admin', 'email' => '*****@*****.**', 'password' => Hash::make('admin')]); $admin_role = Role::whereName('admin')->first(); $developer_role = Role::whereName('developer')->first(); if ($admin_role) { $admin->attachRole($admin_role); } if ($developer_role) { $developer->attachRole($developer_role); $developer->attachRole($admin_role); } }
/** * Load a guest user model, used for reading roles and permissions * * @return User */ public static function loadGuest() { $guest = new static(); $guest_role = Role::with('permissions')->where('name', 'guest')->get(); return $guest->setRelation('roles', $guest_role); }