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


PHP Role::firstOrCreate方法代码示例

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


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

示例1: run

 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $admin = Role::firstOrCreate(['name' => 'admin', 'display_name' => 'Administrator', 'description' => 'Member is an administrator']);
     $member = Role::firstOrCreate(['name' => 'member', 'display_name' => 'Member', 'description' => 'Generic membership role']);
     $mentor = Role::firstOrCreate(['name' => 'mentor', 'display_name' => 'Mentor', 'description' => 'Member is a mentor']);
     $officer = Role::firstOrCreate(['name' => 'officer', 'display_name' => 'Officer', 'description' => 'Member is an officer']);
     if (\App::environment('local')) {
         $member = Member::findOrFail(1);
         $member->attachRole($admin);
     }
 }
开发者ID:rit-sse,项目名称:api,代码行数:16,代码来源:RolesTableSeeder.php

示例2: setOwner

 public function setOwner(User $user)
 {
     $user->forgetPermissions();
     $role = Role::firstOrCreate(['role' => "owner", 'board_uri' => $this->board_uri, 'caste' => NULL, 'inherit_id' => Role::$ROLE_OWNER, 'name' => "Board Owner", 'capcode' => "Board Owner", 'system' => false]);
     return UserRole::create(['user_id' => $user->user_id, 'role_id' => $role->role_id]);
 }
开发者ID:nitogel,项目名称:infinity-next,代码行数:6,代码来源:Board.php

示例3: postRoleCreate

 /**
  * 権限の作成
  */
 public function postRoleCreate(Request $request)
 {
     $role = Role::firstOrCreate($request->only('name'));
     $role->save();
     \Session::flash('flash_message', '権限を作成しました。');
     return redirect()->back();
 }
开发者ID:haruya,项目名称:admin,代码行数:10,代码来源:UsersController.php

示例4: runBoards

 public function runBoards()
 {
     $this->command->comment("\tInserting board owner roles.");
     $boardRole = $this->slugs()[Role::ID_OWNER];
     Board::chunk(50, function ($boards) {
         foreach ($boards as $board) {
             $boardRole = $board->getOwnerRole();
             if (!$boardRole) {
                 $boardRole = Role::getOwnerRoleForBoard($board);
                 $this->command->line("\t/{$board->board_uri}/ has no owner role.");
             }
             $roleModel = Role::firstOrCreate(['role' => $boardRole['role'], 'board_uri' => $board->board_uri, 'caste' => $boardRole['caste']]);
             if ($roleModel->wasRecentlyCreated) {
                 $roleModel->fill(['name' => $boardRole['name'], 'capcode' => $boardRole['capcode'], 'inherit_id' => Role::ID_OWNER, 'system' => false, 'weight' => $boardRole['weight'] + 5])->save();
             }
         }
     });
 }
开发者ID:LulzNews,项目名称:infinity-next,代码行数:18,代码来源:RoleSeeder.php


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