本文整理汇总了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]);
}
示例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);
}
}
}
示例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);
}
}
}
示例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);
}
}
}
示例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);
}
}
}