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


PHP Permission::create方法代码示例

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


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

示例1: registerPermissionsCreate

 /**
  * Create new Permission;
  * @param $name
  * @param $perm
  */
 private function registerPermissionsCreate($name, $perm)
 {
     $flag = Permission::where('name', '=', $name . '.' . $perm)->first();
     if (empty($flag)) {
         Permission::create(['name' => $name . '.' . $perm, 'display_name' => $this->registerPermissionsDisplay($perm), 'description' => '']);
     }
 }
开发者ID:vnzacky,项目名称:dog,代码行数:12,代码来源:TraitServiceProvider.php

示例2: store

 public function store(Request $request)
 {
     $keys = 'name,display_name,description';
     $data = $this->autoValidate($request, 'permission.store', $keys);
     Permission::create($data);
     return $this->success('', url('admin/permission'));
 }
开发者ID:unionbt,项目名称:hanpaimall,代码行数:7,代码来源:PermissionController.php

示例3: permission_edit

 public function permission_edit(Request $request)
 {
     $this->validate($request, array('permission' => 'required', 'permission_name' => 'required'));
     //check repeat before operate the database
     $error_msg_route = 'This route has already existed!';
     $error_msg_route_name = 'This route name has already existed!';
     if (!$request->input('id')) {
         if (Permission::where('permission', $request->input('permission'))->first()) {
             return redirect()->back()->withErrors($error_msg_route);
         }
         if (Permission::where('permission_name', $request->input('permission_name'))->first()) {
             return redirect()->back()->withErrors($error_msg_route_name);
         }
         $lastInsert = Permission::create($request->all());
         PermissionRole::create(array('permission_id' => $lastInsert->id, 'role_id' => 1));
     } else {
         $self = Permission::find($request->input('id'));
         if ($self->permission != $request->input('permission') && Permission::where('permission', $request->input('permission'))->first()) {
             return redirect()->back()->withErrors($error_msg_route);
         }
         if ($self->permission_name != $request->input('permission_name') && Permission::where('permission_name', $request->input('permission_name'))->first()) {
             return redirect()->back()->withErrors($error_msg_route_name);
         }
         Permission::find($request->input('id'))->update($request->all());
     }
     return redirect()->back();
 }
开发者ID:Aylchen,项目名称:laravel5,代码行数:27,代码来源:AdminController.php

示例4: store

 /**
  * do add data
  * @param mixed $request
  * @return redirect
  */
 public function store(Request $request)
 {
     $messages = ['name.required' => 'Permission name is necessary!'];
     $this->validate($request, ['name' => 'required'], $messages);
     Permission::create($request->all());
     return redirect(route('admin.permission.index'))->with('info', 'Added Successfully~~');
 }
开发者ID:Jokeramc,项目名称:amc,代码行数:12,代码来源:PermissionController.php

示例5: run

 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     // Create Roles
     $subscriberRole = Role::create(['name' => '订阅者', 'slug' => 'subscriber']);
     $contributorRole = Role::create(['name' => '投稿者', 'slug' => 'contributor']);
     $authorRole = Role::create(['name' => '作者', 'slug' => 'author']);
     $editorRole = Role::create(['name' => '编辑', 'slug' => 'editor']);
     $adminRole = Role::create(['name' => '管理员', 'slug' => 'admin']);
     // Create Permission
     $createArticlePermission = Permission::create(['name' => '发布文章', 'slug' => 'article.create']);
     $uploadImagePermission = Permission::create(['name' => '上传图片', 'slug' => 'image.upload']);
     $manageArticlePermission = Permission::create(['name' => '文章管理', 'slug' => 'article.manage']);
     $manageImagePermission = Permission::create(['name' => '图片管理', 'slug' => 'image.manage']);
     $manageUserPermission = Permission::create(['name' => '用户管理', 'slug' => 'user.manage']);
     $contributorRole->assignPermission($createArticlePermission->id);
     $authorRole->assignPermission($createArticlePermission->id);
     $authorRole->assignPermission($uploadImagePermission->id);
     $editorRole->assignPermission($createArticlePermission->id);
     $editorRole->assignPermission($uploadImagePermission->id);
     $editorRole->assignPermission($manageArticlePermission->id);
     $editorRole->assignPermission($manageImagePermission->id);
     // Create User
     $admin = User::create(['name' => env('ADMIN_NAME', 'Admin'), 'email' => env('ADMIN_EMAIL', 'admin@laravel.blog'), 'password' => bcrypt(env('ADMIN_PASSWORD', 'password'))]);
     if (!$admin->save()) {
         Log::info('Unable to create admin ' . $admin->username, (array) $admin->errors());
     } else {
         $admin->assignRole($adminRole->id);
         Log::info('Created admin "' . $admin->username . '" <' . $admin->email . '>');
     }
 }
开发者ID:litemax,项目名称:LaravelBlog,代码行数:35,代码来源:RoleAndUserTableSeeder.php

示例6: run

 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     DB::table('permissions')->truncate();
     Permission::create(['name' => 'can-create-request', 'display_name' => 'Can create request', 'description' => 'Allows the user to submit a new request']);
     Permission::create(['name' => 'can-approve-request', 'display_name' => 'Can approve request', 'description' => 'User can approve submitted requests']);
     Permission::create(['name' => 'can-admin', 'display_name' => 'Can Admin', 'description' => 'User can so anything']);
 }
开发者ID:gfdeveloper,项目名称:LCCB,代码行数:12,代码来源:PermissionsTableSeeder.php

示例7: run

 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     Role::create(['name' => 'manager_receive', 'label' => 'Manager of Receive.']);
     Role::create(['name' => 'manager_requesition', 'label' => 'Manager of Requesition.']);
     Role::create(['name' => 'manager_product_list', 'label' => 'Manager of Product list.']);
     Role::create(['name' => 'manager_product', 'label' => 'Manager of Product.']);
     Role::create(['name' => 'manager_product_type', 'label' => 'Manager of Product Type.']);
     Role::create(['name' => 'manager_unit', 'label' => 'Manager of Unit.']);
     Role::create(['name' => 'manager_location', 'label' => 'Manager of Location.']);
     Role::create(['name' => 'manager_project', 'label' => 'Manager of Project.']);
     Role::create(['name' => 'manager_user', 'label' => 'Manager of User.']);
     Permission::create(['name' => 'create_form', 'label' => 'Create of form.']);
     Permission::create(['name' => 'update_form', 'label' => 'Update of form.']);
     Permission::create(['name' => 'delete_form', 'label' => 'Delete of form.']);
     $roles = Role::all();
     $permissions = Permission::all();
     foreach ($roles as $role) {
         foreach ($permissions as $permission) {
             $role->givePermissionTo($permission);
         }
     }
     $user = User::whereEmail('n_vasit@hotmail.com')->first();
     foreach ($roles as $role) {
         $user->assignRole($role->name);
     }
     $user = User::whereEmail('akarin@mixed.co.th')->first();
     foreach ($roles as $role) {
         $user->assignRole($role->name);
     }
 }
开发者ID:vasitjuntong,项目名称:mixed,代码行数:35,代码来源:RolesSeeder.php

示例8: run

 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $admin = Role::create(['name' => 'admin', 'display_name' => 'Administrator']);
     $managePieces = Permission::create(['name' => 'manage-pieces', 'display_name' => 'create and edit pieces']);
     $admin->attachPermission($managePieces);
     $super = User::where('email', 'steve@evendev.com')->first()->attachRole($admin);
 }
开发者ID:evendev,项目名称:paintsip,代码行数:12,代码来源:RolePermSeeder.php

示例9: store

 /**
  * Store a newly created resource in storage.
  *
  * @param \Illuminate\Http\Request $request
  *
  * @return void
  */
 public function store(Request $request)
 {
     $this->validate($request, ['name' => 'required']);
     Permission::create($request->all());
     Session::flash('flash_message', 'Permission added!');
     return redirect('admin/permissions');
 }
开发者ID:appzcoder,项目名称:laravel-admin,代码行数:14,代码来源:PermissionsController.php

示例10: run

 public function run()
 {
     // create roles
     $admin = Role::create(['name' => 'admin', 'display_name' => 'Admin', 'description' => 'performs administrative tasks', 'created_at' => date('Y-m-d H:i:s'), 'updated_at' => date('Y-m-d H:i:s')]);
     $cashier = Role::create(['name' => 'cashier', 'display_name' => 'Cashier', 'description' => 'performs cashier tasks', 'created_at' => date('Y-m-d H:i:s'), 'updated_at' => date('Y-m-d H:i:s')]);
     $user = Role::create(['name' => 'user', 'display_name' => 'Portal User', 'description' => 'performs all basic tasks like print receipt, etc...', 'created_at' => date('Y-m-d H:i:s'), 'updated_at' => date('Y-m-d H:i:s')]);
     // create permissions
     $editUser = Permission::create(['name' => 'edit-user', 'display_name' => 'Edit Users', 'description' => 'manage users', 'created_at' => date('Y-m-d H:i:s'), 'updated_at' => date('Y-m-d H:i:s')]);
     $reporting = Permission::create(['name' => 'reporting', 'display_name' => 'Print Report, Print receipt', 'description' => 'manage reports', 'created_at' => date('Y-m-d H:i:s'), 'updated_at' => date('Y-m-d H:i:s')]);
     $editReporting = Permission::create(['name' => 'edit-reporting', 'display_name' => 'Edit Report, Edit receipt', 'description' => 'manage reports', 'created_at' => date('Y-m-d H:i:s'), 'updated_at' => date('Y-m-d H:i:s')]);
     $receipt = Permission::create(['name' => 'view-receipt', 'display_name' => 'View receipt, View Billings', 'description' => 'View recipent and view billings', 'created_at' => date('Y-m-d H:i:s'), 'updated_at' => date('Y-m-d H:i:s')]);
     // assign permissions to roles
     $admin->attachPermissions(array($editUser, $reporting, $receipt, $editReporting));
     $cashier->attachPermissions(array($reporting, $receipt, $editReporting));
     $user->attachPermissions(array($reporting, $receipt));
     // attach admin user to admin role
     $userAdmin = User::where('email', env('ADMIN_EMAIL'))->firstOrFail();
     $userAdmin->attachRole($admin);
     // assign default role to users
     $users = User::all();
     foreach ($users as $normalUser) {
         if ($normalUser->hasRole('user')) {
             continue;
         }
         $normalUser->attachRole($user);
     }
 }
开发者ID:encry2024,项目名称:soa_5,代码行数:27,代码来源:RolesAndPermissionsSeeder.php

示例11: rolesPermissions

 public function rolesPermissions()
 {
     Permission::create(['name' => 'List roles', 'slug' => 'roles-list']);
     Permission::create(['name' => 'Show role', 'slug' => 'roles-show']);
     Permission::create(['name' => 'Create role', 'slug' => 'roles-create']);
     Permission::create(['name' => 'Edit role', 'slug' => 'roles-edit']);
     Permission::create(['name' => 'Delete role', 'slug' => 'roles-delete']);
 }
开发者ID:tassianoalencar,项目名称:mercurios-roles,代码行数:8,代码来源:PermissionsTableSeeder.php

示例12: run

 public function run()
 {
     $faker = Faker::create('en_GB');
     $permissions = [['Owner', true, true, true, true, true], ['Administrator', true, true, true, true, false], ['Editor', true, true, true, false, false], ['Contributor', true, true, false, false, false], ['Reader', true, false, false, false, false]];
     foreach (range(1, count($permissions)) as $index) {
         Permission::create(['name' => $permissions[$index - 1][0], 'read' => (bool) $permissions[$index - 1][1], 'contribute' => (bool) $permissions[$index - 1][2], 'write' => (bool) $permissions[$index - 1][3], 'admin' => (bool) $permissions[$index - 1][4], 'own' => (bool) $permissions[$index - 1][5]]);
     }
 }
开发者ID:jasonb8293,项目名称:fox-api,代码行数:8,代码来源:PermissionsTableSeeder.php

示例13: store

 /**
  * Store a newly created resource in storage.
  *
  * @param  Request  $request
  * @return Response
  */
 public function store(Request $request)
 {
     if (!$this->user->userCan('permission-create')) {
         \App::abort(403, 'Access denied');
     }
     \App\Permission::create($request->all());
     return redirect('/admin/permission');
 }
开发者ID:serovvitaly,项目名称:kotik,代码行数:14,代码来源:PermissionController.php

示例14: store

 /**
  * Store a new role
  */
 public function store(PermissionRequest $request)
 {
     $name = str_slug($request->name, "-");
     $label = $request->name;
     $permission = Permission::create(['name' => $name, 'label' => $label]);
     logThis('New Permission Created: ' . $permission->name . '(' . $permission->label . ')');
     return $permission;
 }
开发者ID:goatatwork,项目名称:access2,代码行数:11,代码来源:PermissionsApiController.php

示例15: run

 public function run()
 {
     $faker = Faker::create('en_US');
     /*
      * Base User Accounts
      */
     // Mike's account
     $michael = User::create(['name' => 'Michael Norris', 'email' => 'mstnorris@gmail.com', 'password' => bcrypt('password'), 'created_at' => Carbon::now(), 'updated_at' => Carbon::now()]);
     // Super Administrator (User)
     $superU = User::create(['name' => 'Super Administrator', 'email' => 'super@laravel-ums.dev', 'password' => bcrypt('password'), 'created_at' => Carbon::now(), 'updated_at' => Carbon::now()]);
     // Administrator (User)
     $adminU = User::create(['name' => 'Administrator', 'email' => 'admin@laravel-ums.dev', 'password' => bcrypt('password'), 'created_at' => Carbon::now(), 'updated_at' => Carbon::now()]);
     /*
      * Roles
      */
     // Super Administrator (Role)
     $superR = Role::create(['name' => 'Super Administrator', 'created_at' => Carbon::now(), 'updated_at' => Carbon::now()]);
     // Administrator (Role)
     $adminR = Role::create(['name' => 'Administrator', 'created_at' => Carbon::now(), 'updated_at' => Carbon::now()]);
     // User (Role)
     $basicUserR = Role::create(['name' => 'Basic User', 'created_at' => Carbon::now(), 'updated_at' => Carbon::now()]);
     /*
      * Permissions
      */
     // Super Administrator (Permission)
     $superP = Permission::create(['name' => 'Super Administrator (Permission)', 'level' => '1000', 'created_at' => Carbon::now(), 'updated_at' => Carbon::now()]);
     // Administrator (Permission)
     $adminP = Permission::create(['name' => 'Administrator (Permission)', 'level' => '500', 'created_at' => Carbon::now(), 'updated_at' => Carbon::now()]);
     // Level 200 (Permission)
     $p200 = Permission::create(['name' => 'Level 200 (Permission)', 'level' => '200', 'created_at' => Carbon::now(), 'updated_at' => Carbon::now()]);
     // Level 100 (Permission)
     $p100 = Permission::create(['name' => 'Level 100 (Permission)', 'level' => '100', 'created_at' => Carbon::now(), 'updated_at' => Carbon::now()]);
     // Level 50 (Permission)
     Permission::create(['name' => 'Level 50 (Permission)', 'level' => '50', 'created_at' => Carbon::now(), 'updated_at' => Carbon::now()]);
     // Level 20 (Permission)
     Permission::create(['name' => 'Level 20 (Permission)', 'level' => '20', 'created_at' => Carbon::now(), 'updated_at' => Carbon::now()]);
     // Level 10 (Permission)
     Permission::create(['name' => 'Level 10 (Permission)', 'level' => '10', 'created_at' => Carbon::now(), 'updated_at' => Carbon::now()]);
     // Level 5 (Permission)
     Permission::create(['name' => 'Level 5 (Permission)', 'level' => '5', 'created_at' => Carbon::now(), 'updated_at' => Carbon::now()]);
     // Level 2 (Permission)
     Permission::create(['name' => 'Level 2 (Permission)', 'level' => '2', 'created_at' => Carbon::now(), 'updated_at' => Carbon::now()]);
     // Level 1 (Permission)
     Permission::create(['name' => 'Level 1 (Permission)', 'level' => '1', 'created_at' => Carbon::now(), 'updated_at' => Carbon::now()]);
     // Level 0 (Permission)
     Permission::create(['name' => 'Level 0 (Permission)', 'level' => '0', 'created_at' => Carbon::now(), 'updated_at' => Carbon::now()]);
     /*
      * Detailed User Accounts with Roles and Permissions
      */
     $superU->roles()->attach($superR);
     $adminU->roles()->attach($adminR);
     $superR->permissions()->attach($superP);
     $adminR->permissions()->attach($adminP);
     $michael->roles()->attach($superR);
     factory(User::class, 50)->create()->each(function ($u) use($basicUserR) {
         $u->roles()->attach($basicUserR);
     });
 }
开发者ID:sezertunca,项目名称:laravel-ums,代码行数:58,代码来源:ConstantsTableSeeder.php


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