本文整理汇总了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;
}
}
示例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');
}
示例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;
}
示例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);
}
}
示例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));
}
}
示例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')));
}
示例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;
}