當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Permission::firstOrCreate方法代碼示例

本文整理匯總了PHP中Permission::firstOrCreate方法的典型用法代碼示例。如果您正苦於以下問題:PHP Permission::firstOrCreate方法的具體用法?PHP Permission::firstOrCreate怎麽用?PHP Permission::firstOrCreate使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Permission的用法示例。


在下文中一共展示了Permission::firstOrCreate方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: run

 public function run()
 {
     $admin = Role::firstOrCreate(['name' => 'Admin']);
     $secretary = Role::firstOrCreate(['name' => 'Secretary']);
     $technicalReviewer = Role::firstOrCreate(['name' => 'Technical Reviewer']);
     $executive = Role::firstOrCreate(['name' => 'Executive']);
     $procurement = Role::firstOrCreate(['name' => 'Procurement']);
     // Users
     $manageUsers = Permission::firstOrCreate(['name' => 'manage_users', 'display_name' => 'Manage users']);
     // Customers
     $manageCustomers = Permission::firstOrCreate(['name' => 'manage_customers', 'display_name' => 'Manage customers']);
     // Quotations
     $viewSales = Permission::firstOrCreate(['name' => 'view_sales', 'display_name' => 'View sales module']);
     $createQuotations = Permission::firstOrCreate(['name' => 'create_quotations', 'display_name' => 'Create quotations']);
     $viewQuotationRequest = Permission::firstOrCreate(['name' => 'view_request', 'display_name' => 'View quotation request']);
     $editQuotationRequest = Permission::firstOrCreate(['name' => 'edit_request', 'display_name' => 'Edit quotation request']);
     // Bill of materials
     $viewBom = Permission::firstOrCreate(['name' => 'view_bom', 'display_name' => 'View bill of materials']);
     $editBom = Permission::firstOrCreate(['name' => 'edit_bom', 'display_name' => 'Review quotations']);
     // Approval
     $viewApproval = Permission::firstOrCreate(['name' => 'view_approval', 'display_name' => 'View approval']);
     $editApproval = Permission::firstOrCreate(['name' => 'edit_approval', 'display_name' => 'Approve quotations']);
     $seePricing = Permission::firstOrCreate(['name' => 'see_pricing', 'display_name' => 'See prices']);
     // Summary
     $viewSummary = Permission::firstOrCreate(['name' => 'view_summary', 'display_name' => 'View quotation summary']);
     $editSummary = Permission::firstOrCreate(['name' => 'edit_summary', 'display_name' => 'Edit quotation summary']);
     // Direct Award
     $directAward = Permission::firstOrCreate(['name' => 'direct_award', 'display_name' => 'Can issue direct awards']);
     $admin->perms()->sync([$manageUsers->id]);
     $secretary->perms()->sync([$viewSales->id, $manageCustomers->id, $viewQuotationRequest->id, $editQuotationRequest->id, $createQuotations->id, $viewSummary->id, $editSummary->id]);
     $technicalReviewer->perms()->sync([$viewSales->id, $viewBom->id, $editBom->id, $directAward->id]);
     $executive->perms()->sync([$viewSales->id, $manageCustomers->id, $editQuotationRequest->id, $viewQuotationRequest->id, $viewBom->id, $editBom->id, $viewApproval->id, $editApproval->id, $seePricing->id, $viewSummary->id, $editSummary->id, $directAward->id]);
     $procurement->perms()->sync([$viewSales->id, $seePricing->id]);
 }
開發者ID:razerbite,項目名稱:frisco_foundry,代碼行數:34,代碼來源:RolesTableSeeder.php

示例2: run

 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     Model::unguard();
     // $this->call("OthersTableSeeder");
     $permissions = [['name' => 'اضافة برنامج', 'slug' => 'create.supportprograms', 'module' => 'supportprograms'], ['name' => 'عرض البرامج', 'slug' => 'index.supportprograms', 'module' => 'supportprograms'], ['name' => 'تعديل برنامج', 'slug' => 'edit.supportprograms', 'module' => 'supportprograms'], ['name' => 'عرض برنامج', 'slug' => 'show.supportprograms', 'module' => 'supportprograms'], ['name' => 'حذف برنامج', 'slug' => 'delete.supportprograms', 'module' => 'supportprograms']];
     $users = User::where('id', '<', 13)->get();
     foreach ($permissions as $permission) {
         $perm = Permission::firstOrCreate($permission);
         foreach ($users as $user) {
             $user->attachPermission($perm);
         }
     }
 }
開發者ID:hisambahaa,項目名稱:DARES,代碼行數:18,代碼來源:PermissionsTableSeeder.php

示例3: run

 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     Model::unguard();
     // $this->call("OthersTableSeeder");
     $permissions = array(array('name' => 'عرض الاعلان', 'slug' => 'view.announcement', 'module' => 'announcement'), array('name' => 'إضافة الاعلان', 'slug' => 'create.announcement', 'module' => 'announcement'), array('name' => 'تعديل الاعلان', 'slug' => 'edit.announcement', 'module' => 'announcement'), array('name' => 'حذف الاعلان', 'slug' => 'delete.announcement', 'module' => 'announcement'), array('name' => 'تفاصيل الاعلان', 'slug' => 'detail.announcement', 'module' => 'announcement'));
     $users = User::where('id', '<', 13)->get();
     // Permission::where('module' ,'announcement')->delete();
     foreach ($permissions as $permission) {
         $perm = Permission::firstOrCreate($permission);
         foreach ($users as $user) {
             $user->attachPermission($perm);
         }
     }
 }
開發者ID:hisambahaa,項目名稱:DARES,代碼行數:19,代碼來源:PermissionsTableSeeder.php

示例4: run

 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     Model::unguard();
     // $this->call("OthersTableSeeder");
     $permissions = array(array('name' => 'عرض بيانات الاتصال', 'slug' => 'index.callinglog', 'module' => 'callinglog'), array('name' => 'إضافة بيانات اتصال', 'slug' => 'create.callinglog', 'module' => 'callinglog'), array('name' => 'تعديل بيانات اتصال', 'slug' => 'edit.callinglog', 'module' => 'callinglog'), array('name' => 'حذف بيانات اتصال', 'slug' => 'delete.callinglog', 'module' => 'callinglog'));
     $users = User::where('id', '<', 13)->get();
     // Permission::where('module' ,'callinglog')->delete();
     foreach ($permissions as $permission) {
         $perm = Permission::firstOrCreate($permission);
         foreach ($users as $user) {
             $user->attachPermission($perm);
         }
     }
 }
開發者ID:hisambahaa,項目名稱:DARES,代碼行數:19,代碼來源:PermissionsTableSeeder.php

示例5: run

 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     Model::unguard();
     // $this->call("OthersTableSeeder");
     $permissions = [array('name' => 'عرض كتاب', 'slug' => 'index.book.library', 'module' => 'library'), array('name' => 'إضافة كتاب', 'slug' => 'create.book.library', 'module' => 'library'), array('name' => 'تعديل الكتاب', 'slug' => 'edit.book.library', 'module' => 'library'), array('name' => 'حذف الكتاب', 'slug' => 'delete.book.library', 'module' => 'library'), array('name' => 'عرض التصنيفات', 'slug' => 'index.category.library', 'module' => 'library'), array('name' => 'إضافة تصنيف', 'slug' => 'create.category.library', 'module' => 'library'), array('name' => 'تعديل التصنيف', 'slug' => 'edit.category.library', 'module' => 'library'), array('name' => 'حذف التصنيف', 'slug' => 'delete.category.library', 'module' => 'library')];
     $users = User::where('id', '<', 13)->get();
     // Permission::where('module' ,'library')->delete();
     foreach ($permissions as $permission) {
         $perm = Permission::firstOrCreate($permission);
         foreach ($users as $user) {
             $user->attachPermission($perm);
         }
     }
 }
開發者ID:hisambahaa,項目名稱:DARES,代碼行數:19,代碼來源:PermissionsTableSeeder.php


注:本文中的Permission::firstOrCreate方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。