Files

1079 lines
31 KiB
PHP
Raw Permalink Normal View History

2026-03-15 17:08:23 +07:00
<?php
namespace Modules\Authentication\Database\Seeders;
use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Str;
use Modules\Authentication\Models\User;
use Spatie\Permission\Models\Permission;
use Spatie\Permission\Models\Role;
class PermissionSeeder extends Seeder
{
private $saasAdminPermissionList = [
'dashboard',
'system_admin',
'system_settings',
'database_backup',
'restaurants_index',
'restaurants_create',
'restaurants_edit',
'restaurants_delete',
'restaurants_show',
'role_index',
'role_create',
'role_update',
'role_delete',
'user_index',
'user_create',
'user_update',
'user_delete',
];
private $superAdminPermissionList = [
'dashboard',
'super_admin',
'role_index',
'role_create',
'role_update',
'role_delete',
'user_index',
'user_create',
'user_update',
'user_delete',
// Onboardings
'onboardings_index',
'onboardings_create',
'onboardings_edit',
'onboardings_delete',
'onboardings_show',
'packages_index',
'packages_create',
'packages_edit',
'packages_delete',
'packages_show',
'profile_index',
'profile_edit',
'settings_index',
'settings_create',
'settings_edit',
'customer_addresses_index',
'customer_addresses_create',
'customer_addresses_edit',
'customer_addresses_delete',
'customer_addresses_show',
'delivery_boys_index',
'delivery_boys_create',
'delivery_boys_edit',
'delivery_boys_delete',
'delivery_boys_show',
'delivery_charges_index',
'delivery_charges_create',
'delivery_charges_edit',
'delivery_charges_delete',
'delivery_charges_show',
'order_trackings_index',
'order_trackings_create',
'order_trackings_edit',
'order_trackings_delete',
'order_trackings_show',
'restaurant_schedules_index',
'restaurant_schedules_create',
'restaurant_schedules_edit',
'restaurant_schedules_delete',
'restaurant_schedules_show',
'about_us_index',
'about_us_create',
'about_us_edit',
'about_us_delete',
'about_us_show',
'addons_index',
'addons_create',
'addons_edit',
'addons_delete',
'addons_show',
'attendances_index',
'attendances_create',
'attendances_edit',
'attendances_delete',
'attendances_show',
'awards_index',
'awards_create',
'awards_edit',
'awards_delete',
'awards_show',
'banners_index',
'banners_create',
'banners_edit',
'banners_delete',
'banners_show',
'candidates_index',
'candidates_create',
'candidates_edit',
'candidates_delete',
'candidates_show',
'chefs_index',
'chefs_create',
'chefs_edit',
'chefs_delete',
'chefs_show',
'contacts_index',
'contacts_delete',
'customers_index',
'customers_create',
'customers_edit',
'customers_delete',
'customers_show',
'departments_index',
'departments_create',
'departments_edit',
'departments_delete',
'departments_show',
'designations_index',
'designations_create',
'designations_edit',
'designations_delete',
'designations_show',
'employee_salaries_index',
'employee_salaries_create',
'employee_salaries_edit',
'employee_salaries_delete',
'employee_salaries_show',
'employees_index',
'employees_create',
'employees_edit',
'employees_delete',
'employees_show',
'faqs_index',
'faqs_create',
'faqs_edit',
'faqs_delete',
'faqs_show',
'feedbacks_index',
'feedbacks_create',
'feedbacks_edit',
'feedbacks_delete',
'feedbacks_show',
'food_availabilities_index',
'food_availabilities_create',
'food_availabilities_edit',
'food_availabilities_delete',
'food_availabilities_show',
'food_categories_index',
'food_categories_create',
'food_categories_edit',
'food_categories_delete',
'food_categories_show',
'food_items_index',
'food_items_create',
'food_items_edit',
'food_items_delete',
'food_items_show',
'food_variant_ingredients_index',
'food_variant_ingredients_create',
'food_variant_ingredients_edit',
'food_variant_ingredients_delete',
'food_variant_ingredients_show',
'food_variants_index',
'food_variants_create',
'food_variants_edit',
'food_variants_delete',
'food_variants_show',
'galleries_index',
'galleries_create',
'galleries_edit',
'galleries_delete',
'galleries_show',
'ingredient_damages_index',
'ingredient_damages_create',
'ingredient_damages_edit',
'ingredient_damages_delete',
'ingredient_damages_show',
'ingredients_index',
'ingredients_create',
'ingredients_edit',
'ingredients_delete',
'ingredients_show',
'interviews_index',
'interviews_create',
'interviews_edit',
'interviews_delete',
'interviews_show',
'leave_applications_index',
'leave_applications_create',
'leave_applications_edit',
'leave_applications_delete',
'leave_applications_show',
'leave_types_index',
'leave_types_create',
'leave_types_edit',
'leave_types_delete',
'leave_types_show',
'loan_installments_index',
'loan_installments_create',
'loan_installments_edit',
'loan_installments_delete',
'loan_installments_show',
'loans_index',
'loans_create',
'loans_edit',
'loans_delete',
'loans_show',
'menu_categories_index',
'menu_categories_create',
'menu_categories_edit',
'menu_categories_delete',
'menu_categories_show',
'menu_sections_index',
'menu_sections_create',
'menu_sections_edit',
'menu_sections_delete',
'menu_sections_show',
'menu_types_index',
'menu_types_create',
'menu_types_edit',
'menu_types_delete',
'menu_types_show',
'mobile_app_sections_index',
'mobile_app_sections_create',
'mobile_app_sections_edit',
'mobile_app_sections_delete',
'mobile_app_sections_show',
'orders_index',
'orders_create',
'orders_edit',
'orders_delete',
'orders_show',
'payment_methods_index',
'payment_methods_create',
'payment_methods_edit',
'payment_methods_delete',
'payment_methods_show',
'policies_index',
'policies_create',
'policies_edit',
'policies_delete',
'policies_show',
'purchase_return_index',
'purchase_return_create',
'purchase_return_edit',
'purchase_return_delete',
'purchase_return_show',
'purchases_index',
'purchases_create',
'purchases_edit',
'purchases_delete',
'purchases_show',
'ready_to_join_us_index',
'ready_to_join_us_create',
'ready_to_join_us_edit',
'ready_to_join_us_delete',
'ready_to_join_us_show',
'recruitment_index',
'recruitment_create',
'recruitment_edit',
'recruitment_delete',
'recruitment_show',
'reservation_unavailability_index',
'reservation_unavailability_create',
'reservation_unavailability_edit',
'reservation_unavailability_delete',
'reservation_unavailability_show',
'reservations_index',
'reservations_create',
'reservations_edit',
'reservations_delete',
'reservations_show',
'restaurants_index',
'restaurants_create',
'restaurants_edit',
'restaurants_delete',
'restaurants_show',
'saas_faqs_index',
'saas_faqs_create',
'saas_faqs_edit',
'saas_faqs_delete',
'saas_faqs_show',
'salary_generates_index',
'salary_generates_create',
'salary_generates_edit',
'salary_generates_delete',
'salary_generates_show',
'salary_setups_index',
'salary_setups_create',
'salary_setups_edit',
'salary_setups_delete',
'salary_setups_show',
'salary_types_index',
'salary_types_create',
'salary_types_edit',
'salary_types_delete',
'salary_types_show',
'suppliers_index',
'suppliers_create',
'suppliers_edit',
'suppliers_delete',
'suppliers_show',
'tables_index',
'tables_create',
'tables_edit',
'tables_delete',
'tables_show',
'testimonials_index',
'testimonials_create',
'testimonials_edit',
'testimonials_delete',
'testimonials_show',
'weekly_holidays_index',
'weekly_holidays_create',
'weekly_holidays_edit',
'weekly_holidays_delete',
'weekly_holidays_show',
'why_choose_us_index',
'why_choose_us_create',
'why_choose_us_edit',
'why_choose_us_delete',
'why_choose_us_show',
'zones_index',
'zones_create',
'zones_edit',
'zones_delete',
'zones_show',
'departments_index',
'departments_create',
'departments_edit',
'departments_delete',
'departments_show',
'designations_index',
'designations_create',
'designations_edit',
'designations_delete',
'designations_show',
'salary_types_index',
'salary_types_create',
'salary_types_edit',
'salary_types_delete',
'salary_types_show',
'employees_index',
'employees_create',
'employees_edit',
'employees_delete',
'employees_show',
'shifts_index',
'shifts_create',
'shifts_edit',
'shifts_delete',
'shifts_show',
'employee_shift_assign_index',
'employee_shift_assign_create',
'employee_shift_assign_edit',
'employee_shift_assign_delete',
'employee_shift_assign_show',
'employee_salaries_index',
'employee_salaries_create',
'employee_salaries_edit',
'employee_salaries_delete',
'employee_salaries_show',
'salary_setups_index',
'salary_setups_create',
'salary_setups_edit',
'salary_setups_delete',
'salary_setups_show',
'salary_generates_index',
'salary_generates_create',
'salary_generates_edit',
'salary_generates_delete',
'salary_generates_show',
'attendances_index',
'attendances_create',
'attendances_edit',
'attendances_delete',
'attendances_show',
'leave_types_index',
'leave_types_create',
'leave_types_edit',
'leave_types_delete',
'leave_types_show',
'leave_applications_index',
'leave_applications_create',
'leave_applications_edit',
'leave_applications_delete',
'leave_applications_show',
'weekly_holidays_index',
'weekly_holidays_create',
'weekly_holidays_edit',
'weekly_holidays_delete',
'weekly_holidays_show',
'loans_index',
'loans_create',
'loans_edit',
'loans_delete',
'loans_show',
'loan_installments_index',
'loan_installments_create',
'loan_installments_edit',
'loan_installments_delete',
'loan_installments_show',
'awards_index',
'awards_create',
'awards_edit',
'awards_delete',
'awards_show',
'recruitment_index',
'recruitment_create',
'recruitment_edit',
'recruitment_delete',
'recruitment_show',
'candidates_index',
'candidates_create',
'candidates_edit',
'candidates_delete',
'candidates_show',
'interviews_index',
'interviews_create',
'interviews_edit',
'interviews_delete',
'interviews_show',
'loyalty_points_index',
'loyalty_points_create',
'loyalty_points_edit',
'loyalty_points_delete',
'loyalty_points_show',
'loyalty_redemptions_index',
'loyalty_redemptions_create',
'loyalty_redemptions_edit',
'loyalty_redemptions_delete',
'loyalty_redemptions_show',
'loyalty_point_settings_index',
'loyalty_point_settings_create',
'loyalty_point_settings_edit',
'loyalty_point_settings_delete',
'loyalty_point_settings_show',
'kitchens_index',
'kitchens_create',
'kitchens_edit',
'kitchens_delete',
'kitchens_show',
'kitchen_assigns_index',
'kitchen_assigns_create',
'kitchen_assigns_edit',
'kitchen_assigns_delete',
'kitchen_assigns_show',
'ingredient_damages_index',
'ingredient_damages_create',
'ingredient_damages_edit',
'ingredient_damages_delete',
'ingredient_damages_show',
'delivery_charges_index',
'delivery_charges_create',
'delivery_charges_edit',
'delivery_charges_delete',
'delivery_charges_show',
'delivery_boys_index',
'delivery_boys_create',
'delivery_boys_edit',
'delivery_boys_delete',
'delivery_boys_show',
'order_trackings_index',
'order_trackings_create',
'order_trackings_edit',
'order_trackings_delete',
'order_trackings_show',
'customer_addresses_index',
'customer_addresses_create',
'customer_addresses_edit',
'customer_addresses_delete',
'customer_addresses_show',
'restaurant_schedules_index',
'restaurant_schedules_create',
'restaurant_schedules_edit',
'restaurant_schedules_delete',
'restaurant_schedules_show',
'reservation_settings_index',
'reservation_settings_create',
'reservation_settings_edit',
'reservation_settings_delete',
'reservation_settings_show',
'tax_settings_index',
'tax_settings_create',
'tax_settings_edit',
'tax_settings_delete',
'tax_settings_show',
'qr_menu_settings_index',
'qr_menu_settings_create',
'qr_menu_settings_edit',
'qr_menu_settings_delete',
'qr_menu_settings_show',
'food_wastes_index',
'food_wastes_create',
'food_wastes_edit',
'food_wastes_delete',
'food_wastes_show',
'reports_dashboard',
'reports_ingredients',
'reports_stocks',
'reports_purchases',
'reports_purchase_estimate',
'reports_opening_stock',
/*
|--------------------------------------------------------------------------
| Delivery
|--------------------------------------------------------------------------
*/
'delivery_index',
'delivery_show',
'delivery_create',
'delivery_update_status',
'delivery_assign_rider',
'delivery_cancel',
'delivery_mark_delivered',
'delivery_tracking',
'delivery_status_history',
'rider_index',
'rider_show',
'rider_create',
'rider_update',
'rider_verify',
'rider_suspend',
'rider_reactivate',
'rider_nearby',
'rider_update_location',
'rider_toggle_online',
'rider_update_fcm',
'rider_active_deliveries',
'rider_delivery_history',
'rider_earnings',
'rider_earnings_history',
'rider_payouts',
'rating_index',
'rating_respond',
'rating_mark_helpful',
'rating_mark_not_helpful',
'rating_approve',
'rating_reject',
'rating_feature',
'tip_calculate',
'tip_show',
'tip_process_payment',
'tip_pre_delivery',
'tip_post_delivery',
];
private $managerPermissions = [
'dashboard',
'manager',
'profile_index',
'profile_edit',
// Orders & Delivery
'orders_index',
'orders_create',
'orders_edit',
'orders_delete',
'orders_show',
'order_trackings_index',
'order_trackings_create',
'order_trackings_edit',
'order_trackings_delete',
'order_trackings_show',
'delivery_boys_index',
'delivery_boys_create',
'delivery_boys_edit',
'delivery_boys_delete',
'delivery_boys_show',
'delivery_charges_index',
'delivery_charges_create',
'delivery_charges_edit',
'delivery_charges_delete',
'delivery_charges_show',
// Restaurant Schedules
'restaurant_schedules_index',
'restaurant_schedules_create',
'restaurant_schedules_edit',
'restaurant_schedules_delete',
'restaurant_schedules_show',
// Menu Management
'menu_types_index',
'menu_types_create',
'menu_types_edit',
'menu_types_delete',
'menu_types_show',
'menu_sections_index',
'menu_sections_create',
'menu_sections_edit',
'menu_sections_delete',
'menu_sections_show',
'menu_categories_index',
'menu_categories_create',
'menu_categories_edit',
'menu_categories_delete',
'menu_categories_show',
'food_categories_index',
'food_categories_create',
'food_categories_edit',
'food_categories_delete',
'food_categories_show',
'food_items_index',
'food_items_create',
'food_items_edit',
'food_items_delete',
'food_items_show',
'food_variants_index',
'food_variants_create',
'food_variants_edit',
'food_variants_delete',
'food_variants_show',
'food_variant_ingredients_index',
'food_variant_ingredients_create',
'food_variant_ingredients_edit',
'food_variant_ingredients_delete',
'food_variant_ingredients_show',
// Tables & Reservations
'tables_index',
'tables_create',
'tables_edit',
'tables_delete',
'tables_show',
'reservations_index',
'reservations_create',
'reservations_edit',
'reservations_delete',
'reservations_show',
'reservation_unavailability_index',
'reservation_unavailability_create',
'reservation_unavailability_edit',
'reservation_unavailability_delete',
'reservation_unavailability_show',
// HR (but not system admin)
'employees_index',
'employees_create',
'employees_edit',
'employees_delete',
'employees_show',
'departments_index',
'departments_create',
'departments_edit',
'departments_delete',
'departments_show',
'designations_index',
'designations_create',
'designations_edit',
'designations_delete',
'designations_show',
// Attendance
'attendances_index',
'attendances_create',
'attendances_edit',
'attendances_delete',
'attendances_show',
// Leave
'leave_types_index',
'leave_types_create',
'leave_types_edit',
'leave_types_delete',
'leave_types_show',
'leave_applications_index',
'leave_applications_create',
'leave_applications_edit',
'leave_applications_delete',
'leave_applications_show',
// Ingredients & Damage
'ingredients_index',
'ingredients_create',
'ingredients_edit',
'ingredients_delete',
'ingredients_show',
'ingredient_damages_index',
'ingredient_damages_create',
'ingredient_damages_edit',
'ingredient_damages_delete',
'ingredient_damages_show',
// Purchases
'suppliers_index',
'suppliers_create',
'suppliers_edit',
'suppliers_delete',
'suppliers_show',
'purchases_index',
'purchases_create',
'purchases_edit',
'purchases_delete',
'purchases_show',
'purchase_return_index',
'purchase_return_create',
'purchase_return_edit',
'purchase_return_delete',
'purchase_return_show',
// Customer & Feedback
'customers_index',
'customers_create',
'customers_edit',
'customers_delete',
'customers_show',
'feedbacks_index',
'feedbacks_create',
'feedbacks_edit',
'feedbacks_delete',
'feedbacks_show',
// Gallery, Banners, Website Sections
'banners_index',
'banners_create',
'banners_edit',
'banners_delete',
'banners_show',
'galleries_index',
'galleries_create',
'galleries_edit',
'galleries_delete',
'galleries_show',
'testimonials_index',
'testimonials_create',
'testimonials_edit',
'testimonials_delete',
'testimonials_show',
// Policies & FAQs
'policies_index',
'policies_create',
'policies_edit',
'policies_delete',
'policies_show',
'faqs_index',
'faqs_create',
'faqs_edit',
'faqs_delete',
'faqs_show',
'saas_faqs_index',
'saas_faqs_create',
'saas_faqs_edit',
'saas_faqs_delete',
'saas_faqs_show',
];
private $employeePermissions = [
'dashboard',
'employee',
'profile_index',
'profile_edit',
'attendances_index',
'attendances_create',
'attendances_show',
'leave_applications_index',
'leave_applications_create',
'leave_applications_edit',
'leave_applications_show',
'salary_generates_index',
'salary_generates_show',
'salary_types_index',
'salary_types_show',
'salary_setups_index',
'salary_setups_show',
'employee_salaries_index',
'employee_salaries_show',
];
private $waiterPermissions = [
'dashboard',
'waiter',
'profile_index',
'profile_edit',
// Tables
'tables_index',
'tables_show',
// Orders
'orders_index',
'orders_create',
'orders_edit',
'orders_show',
// Menu (VIEW ONLY)
'menu_types_index',
'menu_types_show',
'menu_sections_index',
'menu_sections_show',
'menu_categories_index',
'menu_categories_show',
'food_categories_index',
'food_categories_show',
'food_items_index',
'food_items_show',
'food_variants_index',
'food_variants_show',
];
private $chefPermissions = [
'dashboard',
'chef',
'profile_index',
'profile_edit',
// Orders (Kitchen)
'orders_index',
'orders_show',
'orders_edit',
// Ingredients for kitchen
'ingredients_index',
'ingredients_show',
'ingredient_damages_index',
'ingredient_damages_create',
'ingredient_damages_index',
'ingredient_damages_show',
];
private $deliveryManPermissions = [
'dashboard',
'delivery_man',
'profile_index',
'profile_edit',
// Orders for delivery
'orders_index',
'orders_show',
'orders_edit',
// Delivery tracking
'order_trackings_index',
'order_trackings_create',
'order_trackings_edit',
'order_trackings_show',
// Delivery boy profile
'delivery_boys_index',
'delivery_boys_show',
];
public function run(): void
{
Permission::updateOrCreate(['name' => 'system_admin', 'guard_name' => 'web']);
Permission::updateOrCreate(['name' => 'system_settings', 'guard_name' => 'web']);
Permission::updateOrCreate(['name' => 'database_backup', 'guard_name' => 'web']);
Permission::updateOrCreate(['name' => 'super_admin', 'guard_name' => 'web']);
Permission::updateOrCreate(['name' => 'manager', 'guard_name' => 'web']);
Permission::updateOrCreate(['name' => 'waiter', 'guard_name' => 'web']);
Permission::updateOrCreate(['name' => 'employee', 'guard_name' => 'web']);
Permission::updateOrCreate(['name' => 'chef', 'guard_name' => 'web']);
Permission::updateOrCreate(['name' => 'delivery_man', 'guard_name' => 'web']);
foreach ($this->superAdminPermissionList as $permission) {
Permission::updateOrCreate(['name' => $permission, 'guard_name' => 'web']);
}
// SAAS Admin
$saasAdminRole = Role::updateOrCreate(['name' => 'SAAS Admin', 'restaurant_id' => null, 'guard_name' => 'web']);
// Create roles with guard names
$systemAdminRole = Role::updateOrCreate(['name' => 'Super Admin', 'restaurant_id' => null, 'guard_name' => 'web']);
// SuperOwner
$restaurantOwnerRole = Role::updateOrCreate(['name' => 'Owner', 'restaurant_id' => null, 'guard_name' => 'web']);
$restaurantMangerRole = Role::updateOrCreate(['name' => 'Manager', 'restaurant_id' => null, 'guard_name' => 'web']);
$restaurantEmployeeRole = Role::updateOrCreate(['name' => 'Employee', 'restaurant_id' => null, 'guard_name' => 'web']);
$restaurantWaiterRole = Role::updateOrCreate(['name' => 'Waiter', 'restaurant_id' => null, 'guard_name' => 'web']);
$restaurantChefRole = Role::updateOrCreate(['name' => 'Chef', 'restaurant_id' => null, 'guard_name' => 'web']);
$restaurantDeliveryManRole = Role::updateOrCreate(['name' => 'Delivery Man', 'restaurant_id' => null, 'guard_name' => 'web']);
/* Assign Permissions to Roles */
$saasAdminRole->syncPermissions($this->saasAdminPermissionList);
$systemAdminRole->syncPermissions($this->superAdminPermissionList);
// Restaurant Owner
$restaurantOwnerRole->syncPermissions($this->superAdminPermissionList);
// Manager
$restaurantMangerRole->syncPermissions($this->managerPermissions);
// Employee
$restaurantEmployeeRole->syncPermissions($this->employeePermissions);
// Waiter
$restaurantWaiterRole->syncPermissions($this->waiterPermissions);
// Chef
$restaurantChefRole->syncPermissions($this->chefPermissions);
// DeliveryMan
$restaurantDeliveryManRole->syncPermissions($this->deliveryManPermissions);
/** Now Create User */
$this->createUser($saasAdminRole, 'SAAS Admin', 'saasadmin@gmail.com', '000000000002', '123456', null);
$this->createUser($systemAdminRole, 'super-admin', 'admin@gmail.com', '00000000000', '123456', null);
// Restaurant Owner
$this->createUser($restaurantOwnerRole, 'Owner 1', 'restaurant1@gmail.com', '00000000001', '123456', 1);
$this->createUser($restaurantOwnerRole, 'Owner 2', 'restaurant2@gmail.com', '00000000021', '123456', 2);
// Restaurant Manger
$this->createUser($restaurantMangerRole, 'Manager 1', 'manager1@gmail.com', '00000000002', '123456', 1);
$this->createUser($restaurantMangerRole, 'Manager 2', 'manager2@gmail.com', '00000000022', '123456', 2);
// Restaurant Employee
$this->createUser($restaurantEmployeeRole, 'Employee 1', 'employee1@gmail.com', '00000000003', '123456', 1);
$this->createUser($restaurantEmployeeRole, 'Employee 2', 'employee2@gmail.com', '00000000023', '123456', 2);
// First 5 Restaurant 1
$this->createUser($restaurantWaiterRole, 'Waiter 1', 'waiter1@gmail.com', '00000000011', '123456', 1);
$this->createUser($restaurantWaiterRole, 'Waiter 2', 'waiter2@gmail.com', '00000000012', '123456', 1);
$this->createUser($restaurantWaiterRole, 'Waiter 3', 'waiter3@gmail.com', '00000000013', '123456', 1);
$this->createUser($restaurantWaiterRole, 'Waiter 4', 'waiter4@gmail.com', '00000000014', '123456', 1);
$this->createUser($restaurantWaiterRole, 'Waiter 5', 'waiter5@gmail.com', '00000000015', '123456', 1);
// First 5 Restaurant 2
$this->createUser($restaurantWaiterRole, 'Waiter 6', 'waiter6@gmail.com', '00000000031', '123456', 2);
$this->createUser($restaurantWaiterRole, 'Waiter 7', 'waiter7@gmail.com', '00000000032', '123456', 2);
$this->createUser($restaurantWaiterRole, 'Waiter 8', 'waiter8@gmail.com', '00000000033', '123456', 2);
$this->createUser($restaurantWaiterRole, 'Waiter 9', 'waiter9@gmail.com', '00000000034', '123456', 2);
$this->createUser($restaurantWaiterRole, 'Waiter 10', 'waiter10@gmail.com', '00000000035', '123456', 2);
// Restaurant Chef
$this->createUser($restaurantChefRole, 'Chef 1', 'chef1@gmail.com', '00000000034', '123456', 1);
$this->createUser($restaurantChefRole, 'Chef 2', 'chef1@gmail.com', '00000000034', '123456', 1);
$this->createUser($restaurantChefRole, 'Chef 1', 'chef2@gmail.com', '000000000044', '123456', 2);
$this->createUser($restaurantChefRole, 'Chef 2', 'chef2@gmail.com', '000000000044', '123456', 2);
// Restaurant DeliveryMan
$this->createUser($restaurantDeliveryManRole, 'DeliveryMan 1', 'deliveryman1@gmail.com', '00000000005', '123456', 1);
$this->createUser($restaurantDeliveryManRole, 'DeliveryMan 2', 'deliveryman2@gmail.com', '000000000025', '123456', 2);
}
public function createUser(Role $role, string $name, string $email, string $phone, string $password, ?int $restaurantId = null)
{
$user = User::factory([
'first_name' => $name,
'email' => $email,
'email_verified_at' => now(),
'password' => Hash::make($password),
'phone' => $phone,
'user_type' => $role->name,
'role_id' => $role->id,
'remember_token' => Str::random(10),
'platform' => 'WEB',
'address' => 'Dhaka, Bangladesh',
'status' => 1,
'created_by' => 1,
'restaurant_id' => $restaurantId,
'created_at' => now(),
'updated_at' => now(),
])->create();
/* Get all the permission and assign admin role */
$user->assignRole([$role->id]);
}
}