本文整理汇总了PHP中app\models\Role::find方法的典型用法代码示例。如果您正苦于以下问题:PHP Role::find方法的具体用法?PHP Role::find怎么用?PHP Role::find使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\models\Role
的用法示例。
在下文中一共展示了Role::find方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: edit
/**
* Show the form for editing the specified resource.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function edit($id)
{
$user = User::find($id);
$role = Role::find($user->type);
$roles = Role::all();
return view('user.edit', compact('user', 'role', 'roles'));
}
示例2: deleteRole
public function deleteRole()
{
$id = \Input::get('id');
$role = Role::find($id);
$retData['status'] = $role->delete() ? 200 : 500;
return \Response::json($retData);
}
示例3: revokePermission
public function revokePermission($id, $permission_id)
{
$role = Role::find($id);
$permission = Permission::find($permission_id);
$role->revokePermission($permission);
return redirect()->back();
}
示例4: checklogin
public function checklogin(Request $request)
{
//print_r($request->all());
$name = $request->get('name');
$code = $request->get('code');
$password = $request->input('password');
if ($code == session('captcha')) {
//$manager = \DB::table('managers')->select('name','password','status')->where('name','=',$name)->get();
$manager = Models\Manager::select('id', 'role_id', 'name', 'password', 'status')->where('name', '=', $name)->first();
if (count($manager) == 1) {
if ($manager->status == 1) {
if ($manager->password == md5(md5($password))) {
session(array('adminid' => $manager->id, 'adminname' => $manager->name));
//获取当前角色拥有的权限并存入session
$role = Models\Role::find($manager->role_id);
$authAllows = array();
foreach ($role->auths as $v) {
$authAllows[] = $v['module_name'] . '.' . $v['controller_name'] . '.' . $v['action_name'];
}
session(array('authAllows' => $authAllows));
return redirect(action('Admin\\IndexController@index'));
} else {
return $this->loginRedirectTo('账号密码错误');
}
} else {
return $this->loginRedirectTo('账号未激活');
}
} else {
return $this->loginRedirectTo('用户不存在');
}
} else {
return $this->loginRedirectTo('验证码不正确');
}
}
示例5: update
public function update($role_id, $name)
{
$role = Role::find($role_id);
$role->name = $name;
$role->save();
return $role;
}
示例6: delete
public function delete($id)
{
/* @var Role $role */
$role = Role::find($id);
$role->delete();
return $role;
}
示例7: getEdit
public function getEdit($id)
{
$this->redirectIfCant('edit', '');
$role = Role::find($id);
$menus = Menu::ofParent(null)->sort()->get();
$this->setSubtitle('Detail - ' . $role->display_label);
return $this->render('backend.pages.security.roles.form', compact('menus', 'role'));
}
示例8: save_per_role
public function save_per_role()
{
$role = Input::get('role');
$prmission = Input::get('permission');
$rolesP = Role::find(Input::get('role'));
$rolesP->attachPermission(Input::get('permission'));
//return view('assign_per_role');
return redirect()->route('assign_per_role');
}
示例9: brokers
public function brokers()
{
$category = Role::find(Config::get('constants.ROLE_BROKER'));
$results = Article::where('category_id', '=', $category->id)->paginate(18);
if (Request::ajax()) {
return Response::json(View::make('articles.category')->withResults($results)->render());
}
return View::make('articles.category')->withCategory($category)->withArticles($results);
}
示例10: getAllRoles
public function getAllRoles()
{
$allRolesobj = Role::find()->select(['RoleId', 'RoleName'])->where(['status' => 'Active'])->all();
$data = ArrayHelper::toArray($allRolesobj, ['RoleId', 'RoleName']);
$roleIdCol = array_column($data, 'RoleId');
$RoleNameCol = array_column($data, 'RoleName');
$RolesData = array_combine($roleIdCol, $RoleNameCol);
return $RolesData;
}
示例11: IndexAdmin
public function IndexAdmin()
{
$opex = Opex::whereYear('fecha', '=', date('Y'))->selectRaw('sum(monto) as monto, fecha as mes')->groupBy(\DB::raw('MONTH(fecha)'))->get();
$alumnos_activos = Role::find(1)->users()->where('cuenta_activa', true)->count();
$alumnos_totales = Role::find(1)->users()->count();
$coachs = Role::find(2)->users()->where('cuenta_activa', true)->count();
$pagos = PagoMensualidad::whereYear('fecha_pago', '=', date('Y'))->selectRaw('sum(monto) as monto, fecha_pago as mes')->groupBy(\DB::raw('MONTH(fecha_pago)'))->get();
return view('admin_home', compact('opex', 'alumnos_activos', 'alumnos_totales', 'pagos', 'coachs'));
}
示例12: rolesArrayBuilder
public static function rolesArrayBuilder()
{
$roles = Role::find()->all();
$rolesIndex = [];
foreach ($roles as $id => $role) {
$rolesIndex[$role->role] = $id + 1;
}
return $rolesIndex;
}
示例13: usersByRole
/**
* List all users
*
* @return response
*/
public function usersByRole($role_id)
{
$role = Role::find($role_id);
if ($role === null) {
throw new NotFoundHttpException();
}
$users = User::where('role_id', $role_id)->paginate(config('back.default_pagination'));
return view('backend::user.index', ['users' => $users, 'avatar_path' => config('back.avatar_path')]);
}
示例14: show
/**
* Display the specified resource.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function show($id)
{
$role = Role::find($id);
if ($role) {
return response()->json(["data" => $role, "result" => "success"], 200);
} else {
return response()->json(["result" => "error"], 200);
}
}
示例15: delete
/**
* Delete role
*
* @param int $id
* @throws SaveException
*/
public function delete($id)
{
try {
$role = RoleModel::find($id);
$role->delete();
} catch (Exception $e) {
throw $e;
}
}