當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。