Files
portal-api/database/seeders/RolesAndPermissions.php
T
baodev0 dfb926055d Add feature tests for domain order management
- Implement AdminDomainOrderTest to cover admin functionalities for domain orders including listing, confirming registration, KYC updates, activation, rejection, and refunds.
- Implement ClientDomainOrderTest to cover client functionalities for placing domain orders, including validation for balance, duplicate orders, and domain normalization.
- Ensure proper handling of domain pricing and service statuses throughout the tests.
2026-07-10 14:16:35 +07:00

167 lines
4.4 KiB
PHP

<?php
namespace Database\Seeders;
use Illuminate\Database\Seeder;
use Spatie\Permission\Models\Permission;
use Spatie\Permission\Models\Role;
class RolesAndPermissions extends Seeder
{
public function run(): void
{
// Reset cached roles and permissions
app()[\Spatie\Permission\PermissionRegistrar::class]->forgetCachedPermissions();
$permissions = [
// Khách hàng
'customer.view',
'customer.create',
'customer.edit',
'customer.destroy',
'customer.manager',
// Nhân sự
'administrator.view',
'administrator.create',
'administrator.edit',
'administrator.destroy',
'administrator.manager',
// Sản phẩm / Dịch vụ
'product-service.view',
'product-service.create',
'product-service.edit',
'product-service.destroy',
'product-service.manager',
// Đơn hàng
'order.view',
'order.create',
'order.edit',
'order.destroy',
'order.manager',
// Hóa đơn
'invoice.view',
'invoice.create',
'invoice.edit',
'invoice.destroy',
'invoice.manager',
// Mã giảm giá
'coupon.view',
'coupon.create',
'coupon.edit',
'coupon.destroy',
'coupon.manager',
// Bài viết
'post.view',
'post.create',
'post.edit',
'post.destroy',
'post.manager',
// Hỗ trợ
'support.view',
'support.create',
'support.edit',
'support.destroy',
'support.manager',
// Thanh toán
'payment.view',
'payment.create',
'payment.edit',
'payment.destroy',
'payment.manager',
// Module DNS
'module-dns.view',
'module-dns.create',
'module-dns.edit',
'module-dns.destroy',
'module-dns.manager',
// Module Hosting
'module-hosting.view',
'module-hosting.create',
'module-hosting.edit',
'module-hosting.destroy',
'module-hosting.manager',
// Module vCenter
'module-vcenter.view',
'module-vcenter.create',
'module-vcenter.edit',
'module-vcenter.destroy',
'module-vcenter.manager',
// IP Pool
'module-ippool.view',
'module-ippool.create',
'module-ippool.edit',
'module-ippool.destroy',
'module-ippool.manager',
// Gói dịch vụ
'package-module.view',
'package-module.create',
'package-module.edit',
'package-module.destroy',
'package-module.manager',
// Email Template
'email-template.view',
'email-template.create',
'email-template.edit',
'email-template.destroy',
'email-template.manager',
// Cài đặt
'setting.manager',
'smtp.manager',
'auto-banking.manager',
'system-log.manager',
// Tên miền
'domain.view',
'domain.create',
'domain.edit',
'domain.destroy',
'domain.manager',
// Vai trò & Phân quyền
'role.view',
'role.create',
'role.edit',
'role.destroy',
'role.manager',
// Menu
'menu.view',
'menu.create',
'menu.edit',
'menu.destroy',
'menu.manager',
];
foreach ($permissions as $name) {
Permission::firstOrCreate([
'name' => $name,
'guard_name' => 'admin',
]);
}
// Full Administrator nhận tất cả quyền
$fullAdmin = Role::where('name', 'Full Administrator')
->where('guard_name', 'admin')
->first();
if ($fullAdmin) {
$fullAdmin->syncPermissions(Permission::where('guard_name', 'admin')->get());
}
}
}