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


PHP Permission::where方法代码示例

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


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

示例1: showPermission

 function showPermission($id)
 {
     $this->data['status'] = Session::has("status") ? Session::get("status") : FALSE;
     $this->data['message'] = Session::has("message") ? Session::get("message") : "";
     $this->data['id'] = $id;
     // GET ALL PERMISSION
     $permissions = Permission::where('group_id', $id)->get()->toArray();
     $permissionMap = array();
     // GET ALL MODULE
     $moduleData = Modules::where('group_id', $id)->get()->toArray();
     if (!empty($permissions)) {
         foreach ($permissions as $permission) {
             $permissionMap[$permission['module_id']][] = $permission;
         }
     }
     if (!empty($moduleData)) {
         $moduleData = array_column($moduleData, 'name', 'id');
     }
     // GET USER PERMISSION
     $groupPermissions = Sentry::findGroupById($id)->getPermissions();
     $this->data['permissionMap'] = $permissionMap;
     $this->data['moduleData'] = $moduleData;
     $this->data['groupPermissions'] = $groupPermissions;
     if (Request::isMethod('post')) {
         $this->postPermission($id, $this->data);
         if ($this->data['status'] === TRUE) {
             return Redirect::to($this->moduleURL . 'permission/' . $this->data['id']);
         }
     }
     $this->layout->content = View::make('showPermission', $this->data);
 }
开发者ID:huycao,项目名称:yoplatform,代码行数:31,代码来源:UserGroupAdminController.php

示例2: run

 public function run()
 {
     $admin = Role::where('name', '=', 'administrator')->first();
     $perms = Permission::all();
     $admin->perms()->sync(array_pluck($perms, 'id'));
     $man = Role::where('name', '=', 'users manager')->first();
     $perms = Permission::where('name', '=', 'manage_users')->orWhere('name', '=', 'delete_users')->get();
     $man->perms()->sync(array_pluck($perms, 'id'));
     $man = Role::where('name', '=', 'premium author')->first();
     $perms = Permission::where('name', '=', 'manage_premium_casts')->orWhere('name', '=', 'manage_free_casts')->orWhere('name', '=', 'manage_series')->get();
     $man->perms()->sync(array_pluck($perms, 'id'));
     $man = Role::where('name', '=', 'author')->first();
     $perms = Permission::where('name', '=', 'manage_free_casts')->orWhere('name', '=', 'manage_series')->get();
     $man->perms()->sync(array_pluck($perms, 'id'));
     $man = Role::where('name', '=', 'eraser')->first();
     $perms = Permission::where('name', '=', 'delete_series')->orWhere('name', '=', 'delete_casts')->get();
     $man->perms()->sync(array_pluck($perms, 'id'));
     $man = Role::where('name', '=', 'premium user')->first();
     $perms = Permission::where('name', '=', 'view_premium_casts')->orWhere('name', '=', 'view_free_casts')->get();
     $man->perms()->sync(array_pluck($perms, 'id'));
     $man = Role::where('name', '=', 'user')->first();
     $perms = Permission::where('name', '=', 'view_free_casts')->get();
     $man->perms()->sync(array_pluck($perms, 'id'));
     $man = Role::where('name', '=', 'guest')->first();
     $perms = Permission::where('name', '=', 'view_free_casts')->get();
     $man->perms()->sync(array_pluck($perms, 'id'));
 }
开发者ID:xfyuan,项目名称:xemecasts,代码行数:27,代码来源:PermissionsTableSeeder.php

示例3: has_permission

 /**
  * Check if a role has a specific permission based on the permission $key
  *
  * @param  string  $key
  * @param  int     $role_id
  * @return bool
  */
 public static function has_permission($key, $role_id)
 {
     if (!isset(static::$permission[$key])) {
         static::$permission[$key] = \Permission::where('permission', '=', $key)->first(array('id'));
     }
     $relation = (bool) static::where('role_id', '=', $role_id)->where('permission_id', '=', static::$permission[$key]->id)->first(array('id'));
     return $relation;
 }
开发者ID:eliasyanni,项目名称:bugs,代码行数:15,代码来源:permission.php

示例4: factory

 public static function factory($id = null)
 {
     $instance = new Permission();
     if (!empty($id)) {
         $instance->where('id', $id)->get();
     }
     return $instance;
 }
开发者ID:jotavejv,项目名称:CMS,代码行数:8,代码来源:permission.php

示例5: permission

function permission($module, $action)
{
    $CI =& get_instance();
    $permission = new Permission();
    $perm = $permission->where("user_type_id = " . $CI->session->userdata('user_type') . " and module = '" . $module . "'")->get();
    if ($perm->{$action}) {
        return TRUE;
    } else {
        return FALSE;
    }
}
开发者ID:unisexx,项目名称:adf16,代码行数:11,代码来源:auth_helper.php

示例6: down

 /**
  * Reverse the migrations.
  *
  * @return void
  */
 public function down()
 {
     Schema::table('c_m_p', function (Blueprint $table) {
         $table->dropForeign('c_m_p_cjenovnik_id_foreign');
         $table->dropForeign('c_m_p_mjera_id_foreign');
         $table->dropForeign('c_m_p_predmet_id_foreign');
     });
     Schema::drop('c_m_p');
     Schema::drop('cjenovnici');
     Permission::where('ime', 'in', array(Permission::PERMISSION_VIEW_CJENOVNIK, Permission::PERMISSION_MANAGE_CJENOVNIK, Permission::PERMISSION_REMOVE_CJENOVNIK))->delete();
 }
开发者ID:Firtzberg,项目名称:Edu,代码行数:16,代码来源:2015_12_19_104358_create_cjenovnici_table.php

示例7: run

 public function run()
 {
     $admin = new Role();
     $admin->name = 'Admin';
     $admin->save();
     $managePages = Permission::where('name', '=', 'manage_pages')->first();
     $manageUsers = Permission::where('name', '=', 'manage_users')->first();
     $manageSermons = Permission::where('name', '=', 'manage_sermons')->first();
     $admin->perms()->sync(array($managePages->id, $manageUsers->id, $manageSermons->id));
     $member = new Role();
     $member->name = 'Member';
     $member->save();
 }
开发者ID:GarethClarridge,项目名称:crockenhill,代码行数:13,代码来源:RoleSeeder.php

示例8: checkRoute

 public function checkRoute()
 {
     if (App::environment() == 'dev') {
         return true;
     }
     $route = Route::currentRouteName();
     $user_id = Auth::id();
     $permission_object = Permission::where('route', '=', $route)->first();
     $permission_id = $permission_object->id;
     $count = $users = DB::table('permission_user')->where('permission_id', '=', $permission_id)->where('user_id', '=', $user_id)->count();
     if ($count > 0) {
         return true;
     } else {
         return false;
     }
 }
开发者ID:helkarakse,项目名称:modpackindex,代码行数:16,代码来源:BaseController.php

示例9: removePermission

 public function removePermission()
 {
     $user_id = Input::get("user");
     $permission_id = Input::get("permission");
     $user = User::find($user_id);
     $permission = PermissionDefinition::find($permission_id);
     if ($user) {
         if ($permission) {
             Permission::where(['permission_id' => $permission_id, 'user_id' => $user_id])->delete();
             return Redirect::to('/dashboard/storyteller/manage/permissions');
         } else {
             return Response::json(['success' => false, 'message' => 'Invalid permission definition.']);
         }
     } else {
         return Response::json(['success' => false, 'message' => 'Invalid user.']);
     }
 }
开发者ID:AcceptableIce,项目名称:Larp3,代码行数:17,代码来源:StorytellerPermissionController.php

示例10: run

 public function run()
 {
     //DB::table('assigned_roles')->delete();
     //DB::table('roles')->delete();
     $admin = Role::create(array('name' => 'admin'));
     $student = Role::create(array('name' => 'student'));
     $teacher = Role::create(array('name' => 'teacher'));
     $permisos = Permission::all();
     foreach ($permisos as $permiso) {
         $admin->attachPermission($permiso);
     }
     $permiso = Permission::where('name', '=', 'crear_examen')->get()->first();
     $teacher->attachPermission($permiso);
     $permiso = Permission::where('name', '=', 'eliminar_examen')->get()->first();
     $teacher->attachPermission($permiso);
     $permiso = Permission::where('name', '=', 'modificar_examen')->get()->first();
     $teacher->attachPermission($permiso);
     $permiso = Permission::where('name', '=', 'realizar_examen')->get()->first();
     $student->attachPermission($permiso);
     $permiso = Permission::where('name', '=', 'ver_resultado_examen')->get()->first();
     $student->attachPermission($permiso);
 }
开发者ID:ReyesPedro,项目名称:PlataformaPreguntas,代码行数:22,代码来源:RolesSeeder.php

示例11: update

 /**
  * Update the specified resource in storage.
  * PUT /roles/{id}
  *
  * @param  int  $id
  * @return Response
  */
 public function update($id)
 {
     $role = Role::findOrFail($id);
     if ($role) {
         $perms = Input::get('perms');
         $permsToAttach = [];
         if (Input::has('perms')) {
             foreach ($perms as $key => $value) {
                 $perm = Permission::where('id', '=', $key)->first();
                 if ($perm) {
                     array_push($permsToAttach, $perm->id);
                 }
             }
         }
         $role->perms()->sync($permsToAttach);
         if (Input::has('display_name')) {
             $role->display_name = Input::get('display_name');
         }
         $role->save();
         return Redirect::to('admin/roles')->with(['roles-notice' => 'Role has been updated']);
     }
     return Redirect::to('admin/roles')->with(['roles-notice' => 'Error updating role']);
 }
开发者ID:vanderlin,项目名称:halp,代码行数:30,代码来源:RolesController.php

示例12: run

 public function run()
 {
     $roles = [['name' => 'Administrator', 'weight' => 3], ['name' => 'Moderator', 'weight' => 2], ['name' => 'User', 'weight' => 1]];
     $permissions = [['weight' => '1', 'node' => 'quote.editor', 'description' => 'The ability to use the editor'], ['weight' => '1', 'node' => 'quote.edit', 'description' => 'The ability to edit an existing quote'], ['weight' => '2', 'node' => 'quote.edit.others', 'description' => 'The ability to edit an existing quote that isn\'t yours'], ['weight' => '1', 'node' => 'quote.new', 'description' => 'The ability to create a new quote'], ['weight' => '2', 'node' => 'quote.approve', 'description' => 'The ability to approve a quote'], ['weight' => '2', 'node' => 'quote.deny', 'description' => 'The ability to deny a quote'], ['weight' => '1', 'node' => 'quote.upvote', 'description' => 'The ability to upvote a quote'], ['weight' => '1', 'node' => 'quote.downvote', 'description' => 'The ability to downvote a quote'], ['weight' => '1', 'node' => 'quote.favorite', 'description' => 'The ability to create favorites'], ['weight' => '1', 'node' => 'user.preferences', 'description' => 'The ability to access user preferences'], ['weight' => '3', 'node' => 'site.preferences', 'description' => 'The ability to access site preferences']];
     foreach ($permissions as $permission) {
         $perm = Permission::firstOrNew(['node' => $permission['node']]);
         $perm->description = $permission['description'];
         $perm->save();
     }
     foreach ($roles as $r) {
         $this->command->info('Adding permissions to ' . $r['name']);
         $role = Role::where('name', $r['name'])->first();
         foreach ($permissions as $p) {
             if ($p['weight'] <= $r['weight']) {
                 $this->command->info('Giving ' . $r['name'] . ' the ' . $p['node'] . ' node');
                 $permission = Permission::where('node', $p['node'])->first();
                 if (!$role->permissions->contains($permission->id)) {
                     $role->permissions()->attach($permission);
                 }
             }
         }
     }
 }
开发者ID:shiftosnext,项目名称:Quotinator,代码行数:23,代码来源:PermissionTableSeeder.php

示例13: permission

 function permission($module, $action, $id = null)
 {
     $CI =& get_instance();
     $foo = new Permission();
     if ($id) {
         $foobar = $foo->where("user_type_id", $id)->where("module", $module)->get(1);
         if ($foobar->{$action}) {
             return TRUE;
         } else {
             return FALSE;
         }
     } else {
         if (user()->fd_admin == 1) {
             return TRUE;
         } else {
             $foobar = $foo->where("user_type_id", user()->user_type_id)->where("module", $module)->get(1);
             if ($foobar->{$action}) {
                 return TRUE;
             } else {
                 return FALSE;
             }
         }
     }
 }
开发者ID:ultraauchz,项目名称:asean_cultural_mapping,代码行数:24,代码来源:authen_helper.php

示例14: destroy

 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     if (ACL::checkUserPermission('permission.delete') == false) {
         return Redirect::action('dashboard');
     }
     $permission = Permission::where('id', $id)->find($id);
     if (!empty($permission)) {
         $permission->delete();
         $messageType = 'success';
         $message = 'Permission delete success';
     } else {
         $messageType = 'error';
         $message = 'Permission delete failed';
     }
     return Redirect::action('settings.permission')->with($messageType, $message);
 }
开发者ID:pacificcasinohotel,项目名称:pointsystem,代码行数:22,代码来源:PermissionController.php

示例15: getPermission

 public function getPermission()
 {
     $this->getUser();
     $this->permission = Permission::where('name', 'TestPermission')->first();
 }
开发者ID:k4ml,项目名称:laravel-base,代码行数:5,代码来源:PermissionsTest.php


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