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


PHP Role::active方法代码示例

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


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

示例1: rules

 /**
  * Get the validation rules that apply to the request.
  *
  * @return array
  */
 public function rules()
 {
     // Validation rules
     $rules = array('label' => 'required|unique:Permissions,label,' . Route::current()->parameter('permission_id') . ',permission_id', 'isActive' => 'required|in:0,1');
     /** $var \Illuminate\Database\Eloquent\Collection $Roles */
     $Roles = Role::active()->get();
     // IF Roles exist, add roles condition
     if ($Roles->count() > 0) {
         // Gets the array of keys
         $keys = $Roles->modelKeys();
         // Add roles to the IN statement
         $rules['roles'] = 'array|in:' . implode(',', $keys);
     }
     return $rules;
 }
开发者ID:JasonTurpin,项目名称:Easy-Payments,代码行数:20,代码来源:UpdatePermissionRequest.php

示例2: rules

 /**
  * Get the validation rules that apply to the request.
  *
  * @return array
  */
 public function rules()
 {
     // Validation rules
     $rules = array('password' => 'required|same:password2|regex:' . config('app.pwRegex'), 'isActive' => 'required|in:0,1', 'email' => 'required|unique:Users,email|email', 'firstName' => 'required', 'lastName' => 'required');
     /** $var \Illuminate\Database\Eloquent\Collection $Roles */
     $Roles = Role::active()->get();
     // IF Roles exist, add roles condition
     if ($Roles->count() > 0) {
         // Gets the array of keys
         $keys = $Roles->modelKeys();
         // Add roles to the IN statement
         $rules['roles'] = 'array|in:' . implode(',', $keys);
     }
     return $rules;
 }
开发者ID:JasonTurpin,项目名称:Easy-Payments,代码行数:20,代码来源:CreateUserRequest.php

示例3: do_editUser

 /**
  * Edit an existing user account
  *
  * @param int $user_id The user being edited ID
  *
  * @return View
  */
 public function do_editUser($user_id)
 {
     // Attempt to find the user
     try {
         $user = User::findOrFail($user_id);
         // IF an invalid user ID was passed, throw a 404
     } catch (ModelNotFoundException $ex) {
         $this->_addDashboardMessage('The user you were looking for does not exist.', 'error');
         return redirect()->route('admin.listusers')->with('dashboardMessages', $this->dashboardMessages);
     }
     // Fetchs old form data
     $oldData = Request::old();
     // IF old form data exists
     if (is_array($oldData) && !empty($oldData)) {
         // Set user roles (is case as array for case of null)
         $userRoles = (array) Request::old('roles');
         // Fill model with old form data
         $user->fill($oldData);
         // Old form data does not exist.  Fetch user roles
     } else {
         $userRoles = $user->roles->modelKeys();
     }
     // Share View Variables
     View::share('user', $user);
     View::share('userRoles', $userRoles);
     View::share('Roles', Role::active()->get());
     View::share('_pageName', 'Edit ' . $user->firstName . ' ' . $user->lastName);
     View::share('_title', 'Edit ' . $user->firstName . ' ' . $user->lastName);
     View::share('_pageAction', '/Admin/updateUser/' . $user->user_id);
     // Render the template
     return $this->_renderTemplate('Admin.User');
 }
开发者ID:JasonTurpin,项目名称:Easy-Payments,代码行数:39,代码来源:AdminController.php


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