当前位置: 首页>>代码示例>>PHP>>正文


PHP Permission::firstOrCreate方法代码示例

本文整理汇总了PHP中app\models\Permission::firstOrCreate方法的典型用法代码示例。如果您正苦于以下问题:PHP Permission::firstOrCreate方法的具体用法?PHP Permission::firstOrCreate怎么用?PHP Permission::firstOrCreate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在app\models\Permission的用法示例。


在下文中一共展示了Permission::firstOrCreate方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: up

 /**
  * Run the migrations.
  *
  * @return void
  */
 public function up()
 {
     $administrator = Role::firstOrCreate(['name' => 'administrator', 'label' => 'Administrator']);
     // Welcome Permissions
     Permission::firstOrCreate(['name' => 'admin.welcome.index', 'label' => 'View Administrator Welcome']);
     // User Permissions
     Permission::firstOrCreate(['name' => 'admin.users.index', 'label' => 'View All Users']);
     Permission::firstOrCreate(['name' => 'admin.users.create', 'label' => 'Create Users']);
     Permission::firstOrCreate(['name' => 'admin.users.edit', 'label' => 'Edit Users']);
     Permission::firstOrCreate(['name' => 'admin.users.show', 'label' => 'View Users']);
     Permission::firstOrCreate(['name' => 'admin.users.destroy', 'label' => 'Delete Users']);
     // Role Permissions
     Permission::firstOrCreate(['name' => 'admin.roles.index', 'label' => 'View All Roles']);
     Permission::firstOrCreate(['name' => 'admin.roles.create', 'label' => 'Create Roles']);
     Permission::firstOrCreate(['name' => 'admin.roles.edit', 'label' => 'Edit Roles']);
     Permission::firstOrCreate(['name' => 'admin.roles.show', 'label' => 'View Roles']);
     Permission::firstOrCreate(['name' => 'admin.roles.destroy', 'label' => 'Delete Roles']);
     // Permission Permissions
     Permission::firstOrCreate(['name' => 'admin.permissions.index', 'label' => 'View All Permissions']);
     Permission::firstOrCreate(['name' => 'admin.permissions.create', 'label' => 'Create Permissions']);
     Permission::firstOrCreate(['name' => 'admin.permissions.edit', 'label' => 'Edit Permissions']);
     Permission::firstOrCreate(['name' => 'admin.permissions.show', 'label' => 'View Permissions']);
     Permission::firstOrCreate(['name' => 'admin.permissions.destroy', 'label' => 'Delete Permissions']);
     // User Permission Permissions
     Permission::firstOrCreate(['name' => 'admin.users.permissions.store', 'label' => 'Add Permissions to Users']);
     Permission::firstOrCreate(['name' => 'admin.users.permissions.destroy', 'label' => 'Remove Permissions from Users']);
     // Role Permission Permissions
     Permission::firstOrCreate(['name' => 'admin.roles.permissions.store', 'label' => 'Add Permissions to Roles']);
     Permission::firstOrCreate(['name' => 'admin.roles.permissions.destroy', 'label' => 'Remove Permissions from Roles']);
     // Role User Permissions
     Permission::firstOrCreate(['name' => 'admin.roles.users.store', 'label' => 'Add Users to Roles']);
     Permission::firstOrCreate(['name' => 'admin.roles.users.destroy', 'label' => 'Remove Users from Roles']);
     $administrator->grant(Permission::all());
 }
开发者ID:stevebauman,项目名称:administration,代码行数:39,代码来源:2014_10_12_300000_seed_roles_and_permissions.php

示例2: update

 /**
  * Update the specified resource in storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function update($id)
 {
     $input = Input::all();
     $postType = $this->postTypeRepos->find($id);
     $postType->update($input);
     $perm = Permission::firstOrCreate(['name' => 'manage-' . $postType->slug, 'display_name' => 'Manage ' . $postType->title, 'description' => 'Ability to add/edit/delete/translate ' . $postType->title]);
     Flash::success('Post Type was updated successfully.');
     return Redirect::route('admin.post-types.list');
 }
开发者ID:elieandraos,项目名称:gaia-posts,代码行数:15,代码来源:PostTypeController.php

示例3: createPermission

 /**
  * Creates a Permission and returns it.
  *
  * @param $name
  * @param $display_name
  * @param $description
  * @param bool $enabled
  * @return \App\Models\Permission
  */
 protected static function createPermission($name, $display_name, $description, $enabled = true)
 {
     $permUseActiveDirectoryInspector = Permission::firstOrCreate(['name' => $name, 'display_name' => $display_name, 'description' => $description, 'enabled' => $enabled]);
     return $permUseActiveDirectoryInspector;
 }
开发者ID:sroutier,项目名称:l51esk-modules,代码行数:14,代码来源:MaintenanceTrait.php

示例4: run

 /**
  * Run the database seeds.
  */
 public function run()
 {
     foreach ($this->permissions as $name => $label) {
         Permission::firstOrCreate(compact('name', 'label'));
     }
 }
开发者ID:stevebauman,项目名称:ithub,代码行数:9,代码来源:PermissionSeeder.php


注:本文中的app\models\Permission::firstOrCreate方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。