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


PHP models\Permission类代码示例

本文整理汇总了PHP中app\models\Permission的典型用法代码示例。如果您正苦于以下问题:PHP Permission类的具体用法?PHP Permission怎么用?PHP Permission使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: run

 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     DB::table('permissions')->delete();
     /**
      * Permission Attributes
      *
      * name:    Unique name for the permission, used for looking up permission information in the
      *             application layer. For example: "create-post", "edit-user", "post-payment", "mailing-list-subscribe".
      *
      * display_name:    Human readable name for the permission. Not necessarily unique, and is optional.
      *                     For example "Create Posts", "Edit Users", "Post Payments", "Subscribe to mailing list".
      *
      * description:     A more detailed explanation of the Permission. This is also optional.
      */
     $permissions = array(self::pArray(PermissionNames::CreateConference(), "Create Conference"), self::pArray(PermissionNames::ManageGlobalPermissions(), "Manage Global Permissions"), self::pArray(PermissionNames::ApproveUserRegistration(), "Approve User Registration"), self::pArray(PermissionNames::ViewSiteStatistics(), "View Site Statistics"), self::pArray(PermissionNames::ManageAccounts(), "Manage Accounts"));
     foreach ($permissions as $p) {
         $entry = new Permission();
         $entry->name = $p['name'];
         if (array_key_exists('display_name', $p)) {
             $entry->display_name = $p['display_name'];
         }
         if (array_key_exists('description', $p)) {
             $entry->description = $p['description'];
         }
         $entry->save();
     }
 }
开发者ID:a161527,项目名称:cs319-p2t5,代码行数:32,代码来源:DefaultPermissionsSeeder.php

示例2: save

 public function save(Request $request)
 {
     $as = $request->input('as');
     $permission = new Permission();
     $validator = \Validator::make($request->all(), $permission->getRules());
     $results = new \StdClass();
     if ($validator->passes()) {
         if ($request->input('id') != "xxx") {
             $permission = Permission::find($request->input('id'));
             $permission->name = $request->input('name');
             $permission->display_name = $request->input('displayname');
             $permission->description = $request->input('description');
             $permission->save();
             $results->info = 'permission create';
         } else {
             $permission = new Permission();
             $permission->name = $request->input('name');
             $permission->display_name = $request->input('displayname');
             $permission->description = $request->input('description');
             $permission->save();
             $results->info = 'permission edit';
         }
         $results->status = 1;
         $results->result = $permission;
     } else {
         $results->status = 0;
         $result = array();
         foreach ($validator->errors() as $key => $err) {
             array_push($result, $err);
         }
         $results->result = $result;
     }
     return response()->json($results);
 }
开发者ID:shofyanugraha,项目名称:egor,代码行数:34,代码来源:PermissionController.php

示例3: run

 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $permissions = new Permission();
     $permissions->name = 'can-access';
     $permissions->display_name = "Dapat Mengakses";
     $permissions->description = "Fungsi Permission";
     $permissions->access = "true";
     $permissions->action = "access";
     $permissions->save();
     $permissions = new Permission();
     $permissions->name = 'can-add';
     $permissions->display_name = "Dapat Menambah";
     $permissions->description = "Fungsi Permission";
     $permissions->access = "true";
     $permissions->action = "add";
     $permissions->save();
     $permissions = new Permission();
     $permissions->name = 'can-edit';
     $permissions->display_name = "Dapat Mengubah";
     $permissions->description = "Fungsi Permission";
     $permissions->access = "true";
     $permissions->action = "edit";
     $permissions->save();
     $permissions = new Permission();
     $permissions->name = 'can-delete';
     $permissions->display_name = "Dapat Menghapus";
     $permissions->description = "Fungsi Permission";
     $permissions->access = "true";
     $permissions->action = "delete";
     $permissions->save();
 }
开发者ID:k1m0ch1,项目名称:egor,代码行数:36,代码来源:PermissionsSeeder.php

示例4: run

 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $permission = new Permission();
     $permission->level = 3;
     $permission->permission = "posts_manage";
     $permission->save();
     $permission = new Permission();
     $permission->level = 4;
     $permission->permission = "users_manage";
     $permission->save();
     $permission = new Permission();
     $permission->level = 5;
     $permission->permission = "permissions_manage";
     $permission->save();
     $permission = new Permission();
     $permission->level = 5;
     $permission->permission = "user_accesses_manage";
     $permission->save();
     User::create(['name' => "admin", 'email' => "admin@admin.ru", 'password' => bcrypt("admin")]);
     $user = User::whereEmail("admin@admin.ru")->first();
     $access = new UserAccess();
     $access->level = 5;
     $access->description = "Is automated created admin user";
     $access->user_id = $user->id;
     $access->save();
 }
开发者ID:thevruno,项目名称:my-own-blog,代码行数:31,代码来源:PermissionsSeeder.php

示例5: run

 public function run()
 {
     $adminEmail = Config::get('madison.seeder.admin_email');
     $admin = new Role();
     $admin->name = 'Admin';
     $admin->save();
     $independent_sponsor = new Role();
     $independent_sponsor->name = 'Independent Sponsor';
     $independent_sponsor->save();
     $permIds = array();
     foreach ($this->adminPermissions as $permClass => $data) {
         $perm = new Permission();
         foreach ($data as $key => $val) {
             $perm->{$key} = $val;
         }
         $perm->save();
         $permIds[] = $perm->id;
     }
     $admin->perms()->sync($permIds);
     $user = User::where('email', '=', $adminEmail)->first();
     $user->attachRole($admin);
     $createDocPerm = new Permission();
     $createDocPerm->name = "independent_sponsor_create_doc";
     $createDocPerm->display_name = "Independent Sponsoring";
     $createDocPerm->save();
     $independent_sponsor->perms()->sync(array($createDocPerm->id));
 }
开发者ID:DCgov,项目名称:dc-madison,代码行数:27,代码来源:RbacSeeder.php

示例6: run

 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     //
     //        $u1 = \App\User::create(
     //            ['name'=>'super_admin', 'email'=>'super_admin@oa.com', 'password'=>Hash::make('123456')]
     //        );
     $user = \App\User::where('email', '=', 'super_admin@oa.com')->first();
     echo $user . "\n";
     //        $role = new \App\Models\Role();
     //        $role->name         = 'SuperUser';
     //        $role->display_name = '超级管理员'; // optional
     //        $role->description  = '网站超管'; // optional
     //        $role->save();
     $role = \App\Models\Role::where('name', '=', 'SuperUser')->first();
     echo $role . "\n";
     //
     //        $user->attachRole($role);
     //
     $permission = new \App\Models\Permission();
     $permission->name = 'create-post';
     $permission->display_name = 'Create Posts';
     // optional
     $permission->description = 'create new blog posts';
     // optional
     $permission->save();
     $role->attachPermission($permission);
 }
开发者ID:jin-yc10,项目名称:oa-test,代码行数:32,代码来源:SuperUserSeeder.php

示例7: update

 /**
  * Update a permission from form request
  *
  * @param Permission $permission
  * @param Request $request
  * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
  */
 public function update(Permission $permission, Request $request)
 {
     $this->authorize('edit_users');
     $this->validate($request, ['name' => 'required|string|between:3,50', 'description' => 'string|between:0,100']);
     $permission->update($request->all());
     $group_list = $request->input('group_list') ?: [];
     $permission->groups()->sync($group_list);
     flash()->success('Permission Saved', 'The permission has been updated');
     return redirect('permission');
 }
开发者ID:buys-fran,项目名称:mtech-mis,代码行数:17,代码来源:PermissionsController.php

示例8: store

 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store()
 {
     //
     $data = new Permission();
     $data->display_name = Input::get('display_name');
     $data->name = Input::get('name');
     $data->desc = Input::get('desc');
     $data->save();
     return redirect()->route('admin.permission.index');
 }
开发者ID:cdandy,项目名称:meta-admin,代码行数:16,代码来源:PermissionController.php

示例9: addPermission

 public static function addPermission($name, $label = null, $description = null)
 {
     $permission = Permission::where('name', $name)->first();
     if (!$permission) {
         $permission = new Permission(['name' => $name]);
     }
     $permission->label = $label;
     $permission->description = $description;
     $permission->save();
     return $permission;
 }
开发者ID:liuzhaowei55,项目名称:Moorper,代码行数:11,代码来源:Permission.php

示例10: store

 /**
  * Adds the requested permissions to the specified role.
  *
  * @param RolePermissionRequest $request
  * @param int|string            $roleId
  *
  * @return array|false
  */
 public function store(RolePermissionRequest $request, $roleId)
 {
     $this->authorize('admin.roles.permissions.store');
     $role = $this->role->findOrFail($roleId);
     $permissions = $request->input('permissions', []);
     if (count($permissions) > 0) {
         $permissions = $this->permission->findMany($permissions);
         return $role->permissions()->saveMany($permissions);
     }
     return false;
 }
开发者ID:stevebauman,项目名称:administration,代码行数:19,代码来源:RolePermissionProcessor.php

示例11: store

 /**
  * Adds the requested permissions to the specified user.
  *
  * @param UserPermissionRequest $request
  * @param int|string            $userId
  *
  * @return array|false
  */
 public function store(UserPermissionRequest $request, $userId)
 {
     $this->authorize('admin.users.permissions.store');
     $user = $this->user->findOrFail($userId);
     $permissions = $request->input('permissions', []);
     if (count($permissions) > 0) {
         $permissions = $this->permission->findMany($permissions);
         return $user->permissions()->saveMany($permissions);
     }
     return false;
 }
开发者ID:stevebauman,项目名称:administration,代码行数:19,代码来源:UserPermissionProcessor.php

示例12: store

 /**
  * Adds the requested permissions to the specified user.
  *
  * @param UserPermissionRequest $request
  * @param int|string            $userId
  *
  * @return \Illuminate\Http\RedirectResponse
  */
 public function store(UserPermissionRequest $request, $userId)
 {
     $this->authorize('admin.users.permissions.store');
     $user = $this->user->findOrFail($userId);
     $permissions = $request->input('permissions', []);
     if (count($permissions) > 0) {
         $permissions = $this->permission->findMany($permissions);
         $user->permissions()->saveMany($permissions);
         flash()->success('Success!', 'Successfully added permissions.');
         return redirect()->route('admin.users.show', [$userId]);
     }
     flash()->error('Error!', "You didn't select any permissions.");
     return redirect()->route('admin.users.show', [$userId]);
 }
开发者ID:stevebauman,项目名称:ithub,代码行数:22,代码来源:UserPermissionController.php

示例13: create

 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function create(Request $request)
 {
     $validator = Validator::make($request->all(), ['name' => 'required|between:4,100|unique:permissions', 'display_name' => 'between:0,100', 'description' => 'between:0,255']);
     if ($validator->fails()) {
         return response()->json(["msg" => "alert", "validator" => $validator->messages()], 200);
     }
     $permission = new Permission();
     $permission->name = $request->name;
     $permission->display_name = $request->display_name;
     // optional
     $permission->description = $request->description;
     // optional
     $permission->save();
 }
开发者ID:whoOami,项目名称:potential-smd,代码行数:19,代码来源:PermissionController.php

示例14: index

 /**
  * @return \Illuminate\View\View
  */
 public function index()
 {
     // Log action by user.
     Audit::log(Auth::user()->id, trans('admin/menu-builder/menu-builder.audit-log.category'), trans('admin/menu-builder/menu-builder.audit-log.msg-index'));
     // Set page title and description.
     $page_title = trans('admin/menu-builder/menu-builder.page.index.title');
     $page_description = trans('admin/menu-builder/menu-builder.page.index.description');
     // Load all menus ordered by Parent (asc), Position (asc), Label (asc) and finally ID (asc).
     $menus = Menu::orderBy('parent_id', 'ASC')->orderBy('position', 'ASC')->orderBy('label', 'ASC')->orderBy('id', 'ASC')->get();
     // Convert menu query result to JSON for JSTree
     $menusJson = $this->menusOrmToJsTreeJson($menus);
     // List label and id of all menus ordered by Label (asc).
     $parents = Menu::where('separator', '0')->orderBy('label', 'ASC')->orderBy('id', 'ASC')->get()->lists('label', 'id');
     // Convert to array.
     $parents = $parents->toArray();
     // List name and id of all routes ordered by Name (asc).
     $routes = Route::whereNotNull('name')->orderBy('name', 'ASC')->get()->lists('name', 'id');
     // Convert to array.
     $routes = $routes->toArray();
     // Add a blank option at the top.
     $routes = array('blank' => '') + $routes;
     // List display name and id of all permissions ordered by Name (asc).
     $permissions = Permission::orderBy('name', 'ASC')->get()->lists('display_name', 'id');
     // Convert to array.
     $permissions = $permissions->toArray();
     // Add a blank option at the top.
     $permissions = array('blank' => '') + $permissions;
     // Return view
     return view('admin.menus.index', compact('menus', 'menusJson', 'parents', 'routes', 'permissions', 'page_title', 'page_description'));
 }
开发者ID:sroutier,项目名称:laravel-5.1-enterprise-starter-kit,代码行数:33,代码来源:MenusController.php

示例15: all

 public function all($params)
 {
     $params['order'] = isset($params['order']) ? $params['order'] : ['display_name|ASC'];
     $permissions = Permission::select("permissions.*");
     $permissions = parent::execute($permissions, $params);
     return $permissions;
 }
开发者ID:pinkynrg,项目名称:convergence2.0,代码行数:7,代码来源:PermissionsController.php


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