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


PHP Permission::whereIn方法代码示例

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


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

示例1: run

 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     DB::table('roles')->delete();
     /**
      * Role Attributes
      *
      * name:    Unique name for the permission, used for looking up permission information in the
      *             application layer. For example: "create-post", "edit-user", "post-payment", "mailing-list-subscribe".
      *
      * display_name:    Human readable name for the permission. Not necessarily unique, and is optional.
      *                     For example "Create Posts", "Edit Users", "Post Payments", "Subscribe to mailing list".
      *
      * description:     A more detailed explanation of the Role. This is also optional.
      *
      * permissions: A list of permission names to assign to the user.  Optional.
      */
     $roles = array(array('name' => 'owner', 'display_name' => 'Owner', 'description' => 'Owner of the management system. Has access to all aspects of the system.', 'permissions' => PermissionNames::AllGlobalPermissions()));
     foreach ($roles as $r) {
         $entry = new Role();
         $entry->name = $r['name'];
         if (array_key_exists('permissions', $r)) {
             $permissions = $r['permissions'];
             unset($r['permissions']);
         }
         if (array_key_exists('display_name', $r)) {
             $entry->display_name = $r['display_name'];
         }
         if (array_key_exists('description', $r)) {
             $entry->description = $r['description'];
         }
         $entry->save();
         if (isset($permissions)) {
             foreach ($permissions as $p) {
                 $entry->attachPermission(Permission::where('name', $p)->get()->first());
             }
             unset($permissions);
         }
     }
     $rolePermissions = Permission::whereIn('name', PermissionNames::AllGlobalPermissions())->get();
     RoleCreate::createPermissionRoles($rolePermissions);
 }
开发者ID:a161527,项目名称:cs319-p2t5,代码行数:46,代码来源:DefaultRolesSeeder.php

示例2: destroy

 /**
  * Remove the event given the eventID.
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     if (!Entrust::hasRole(RoleNames::EventManager($id))) {
         return response("Permission not found", 403);
     }
     return DB::transaction(function () use($id) {
         $event = Event::find($id);
         if (is_null($event)) {
             return response("No event for id {$id}.", 404);
         }
         $event->delete();
         Permission::whereIn('name', PermissionNames::AllEventPermissions($id))->delete();
         RoleCreate::deleteEventRoles($id);
         return response()->json(['id' => $event->id]);
     });
 }
开发者ID:a161527,项目名称:cs319-p2t5,代码行数:21,代码来源:Events.php

示例3: delete

 /**
  * Deletes a conference.
  */
 public function delete($id)
 {
     if (!Entrust::can(PermissionNames::ConferenceInfoEdit($id))) {
         return response("", 403);
     }
     DB::transaction(function () use($id) {
         $events = Event::where('conferenceID', $id)->get();
         $pnames = array_merge(PermissionNames::AllConferencePermissions($id), PermissionNames::ExclusiveConferencePermissions($id));
         $evtIds = [];
         foreach ($events as $e) {
             $pnames = array_merge($pnames, PermissionNames::AllEventPermissions($e->id));
             echo $e;
             $evtIds[] = $e->id;
         }
         Permission::whereIn('name', $pnames)->delete();
         RoleCreate::deleteConferenceRoles($id);
         RoleCreate::deleteEventRoles($evtIds);
         Conference::destroy($id);
     });
     Log::info("Conference with ID {$id} deleted");
     return '';
 }
开发者ID:a161527,项目名称:cs319-p2t5,代码行数:25,代码来源:MainController.php

示例4: putPermissionsUpdate

 public function putPermissionsUpdate($id, Request $request)
 {
     $role = Role::findOrFail($id);
     $this->validate($request, ['permissions' => 'required|array']);
     // fetch an id list array of the permissions we need
     $permissions = Permission::whereIn('name', $request->get('permissions', []))->get();
     $ids = [];
     foreach ($permissions as $permission) {
         $ids[] = $permission->id;
     }
     // sync to current role
     $role->permissions()->sync($ids);
     return response()->json(['status' => 'success', 'message' => trans('api.resource_updated', ['resource' => trans('global.role')])])->setStatusCode(200);
 }
开发者ID:fluentkit,项目名称:fluentkit,代码行数:14,代码来源:RolesController.php

示例5: down

 /**
  * Reverse the migrations.
  *
  * @return void
  */
 public function down()
 {
     Permission::whereIn('name', ['view.admin', 'update.application'])->delete();
     Role::whereIn('name', ['administrator', 'manager'])->delete();
 }
开发者ID:fluentkit,项目名称:fluentkit,代码行数:10,代码来源:2016_01_22_141553_create_base_roles_and_permissions.php

示例6: findPermissions

 private static function findPermissions($permissionNames)
 {
     return Permission::whereIn("name", $permissionNames)->get();
 }
开发者ID:a161527,项目名称:cs319-p2t5,代码行数:4,代码来源:RoleCreate.php


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