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


PHP Roles::find方法代码示例

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


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

示例1: UserAclRoles

 function UserAclRoles($user_id = '')
 {
     $show_box['title'] = '获取用户全部角色';
     $return_value = '';
     $roles_idname = array();
     $roles_id = array();
     $sp_roles = Q::ini('appini/sp_role');
     // 第一步:直接从中间表获得用户的全部角色ID
     $user_roles = UsersHaveRoles::find('user_id = ?', intval($user_id))->asArray()->getAll();
     //dump($user_roles);
     // 取出有用的ID,去除deny的ID
     foreach ($user_roles as $value) {
         if ($value['is_include']) {
             $roles_id[] = $value['role_id'];
         }
     }
     //dump ( $roles_id);
     $roles_arr = Roles::find('role_id in (?)', Q::normalize($roles_id, ","))->asArray()->getAll();
     foreach ($roles_arr as $value) {
         $roles_idname[$value['role_id']] = $value['rolename'];
     }
     //dump($roles_idname);
     if (in_array($sp_roles['REPEAL'], $roles_idname)) {
         $return_value = array($value['role_id'] => $sp_roles['REPEAL']);
         return $return_value;
     } elseif (in_array($sp_roles['FREEZE'], $roles_idname)) {
         $return_value = array($value['role_id'] => $sp_roles['FREEZE']);
         return $return_value;
     } elseif (in_array($sp_roles['UNCHECKED'], $roles_idname)) {
         $return_value = array($value['role_id'] => $sp_roles['UNCHECKED']);
         return $return_value;
     } else {
         return $roles_idname;
     }
 }
开发者ID:Debenson,项目名称:openwan,代码行数:35,代码来源:acl.php

示例2: update

 /**
  * Update the specified resource in storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function update(RolesRequest $roles, $id)
 {
     //this is method to saving
     $roles = Roles::find($id);
     $roles->name = Input::get('name');
     $roles->access = json_encode(Input::get('access'));
     $roles->save();
     Session::flash('message', 'You have successfully added Roles');
     return Redirect::to('roles');
 }
开发者ID:asrulsibaoel,项目名称:laravel5,代码行数:16,代码来源:TransactionsController.php

示例3: findIndexedByIds

 /**
  * Find indexed roles by role IDs
  *
  * @param void
  * @return array
  */
 function findIndexedByIds($ids)
 {
     $result = array();
     if (is_foreachable($ids)) {
         $roles = Roles::find(array('conditions' => array('id IN (?)', $ids)));
         if (is_foreachable($roles)) {
             foreach ($roles as $role) {
                 $result[$role->getId()] = $role;
             }
             // foreach
         }
         // if
     }
     // if
     return $result;
 }
开发者ID:NaszvadiG,项目名称:activecollab_loc,代码行数:22,代码来源:Roles.class.php

示例4: editedRoleAction

 public function editedRoleAction($id)
 {
     Input::flash();
     $data = Input::all();
     $rules = array('rolename' => array('min:3', 'required'));
     // Build the custom messages array.
     $messages = array('rolename.min' => 'ชื่อบทบาทจะต้องยาวมากกว่า :min ตัวอักษร', 'rolename.required' => 'กรุณาระบุชื่อบทบาท');
     // Create a new validator instance.
     $validator = Validator::make($data, $rules, $messages);
     if ($validator->passes()) {
         $role = Roles::find($id);
         $ck_role = $role->checkRole($data['rolename']);
         if ($ck_role) {
             $role->role_name = $data['rolename'];
             $role->save();
             return Redirect::to('role')->with('success', 'บันทึกชื่อบทบาทรหัส: ' . $id . ' สำเร็จ.');
         } else {
             return Redirect::to('role-add')->with('warning', 'มีชื่อบทบาทนี้ในระบบแล้ว');
         }
     } else {
         // $errors = $validator->messages();
         return Redirect::to('role-edit/' . $id)->withErrors($validator);
     }
 }
开发者ID:nattaphat,项目名称:cuse2,代码行数:24,代码来源:RoleController.php

示例5: eliminarRol

 public function eliminarRol()
 {
     $rol = Input::get("rol");
     $roles = Permisos::where("role_id", "=", $rol)->get();
     if (count($roles) > 0) {
         return Response::json(array("estado" => "1"));
     } else {
         $role = Role::find($rol);
         $role->delete();
         $permisos = Roles::find($rol);
         $permisos->delete();
         $html = (string) View::make("dashboard.roles.rolesTablaRoles")->with(array("roles" => Role::all()));
         return Response::json(array("estado" => "2", "html" => $html));
     }
 }
开发者ID:prianticonsulting,项目名称:Habitaria,代码行数:15,代码来源:RolesController.php

示例6: deleteIndex

 /**
  * Remove the specified user from storage.
  *
  * @param $role
  * @internal param $id
  * @return Response
  */
 public function deleteIndex($role)
 {
     $id = $role->id;
     if (!$role->delete()) {
         return Api::json(array('result' => 'error', 'error' => Lang::get('core.delete_error')));
     }
     $roles = Roles::find($id);
     return empty($roles) ? Api::json(array('result' => 'success')) : Api::json(array('result' => 'error', 'error' => Lang::get('core.delete_error')));
 }
开发者ID:Aranjedeath,项目名称:l4-starter,代码行数:16,代码来源:AdminRolesController.php

示例7: actionRoleBind

 /**
  * 角色绑定权限
  */
 function actionRoleBind()
 {
     $this->_pathway->addStep('角色绑定权限');
     $id = $this->_context->id;
     $role = Roles::find()->getById($id);
     if ($this->_context->isPOST()) {
         try {
             $permission_ids = $this->_context->permission_ids;
             $permission_ids = $permission_ids != '' ? Q::normalize($permission_ids) : '0';
             $role->permissions = Permissions::find("id in (?)", $permission_ids)->getAll();
             $role->save();
         } catch (QValidator_ValidateFailedException $ex) {
         }
     }
     $permission = Helper_Permissions::getAllPermissions();
     $permission_ids = array();
     foreach ($role->permissions as $v) {
         $permission_ids[] = $v->id;
     }
     $this->_view['role'] = $role;
     $this->_view['permissions'] = $permission;
     $this->_view['permission_ids'] = $permission_ids;
 }
开发者ID:Debenson,项目名称:openwan,代码行数:26,代码来源:aclmanager_controller.php


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