seedProducts(); $this->seedClassPackages(); $this->seedClassPackageProducts(); $this->seedTestFranchisees(); } private function seedProducts(): void { $products = [ [ 'name' => 'Apostila Nível 1', 'sku' => 'AP-NV1', 'barcode' => '7890001000001', 'price_cost' => 18.00, 'price_sale' => 35.00, 'measure_unit' => 'UN', 'kit' => false, 'visible_franchisee' => true, 'weight' => 0.300, 'length' => 29.7, 'height' => 21.0, ], [ 'name' => 'Apostila Nível 2', 'sku' => 'AP-NV2', 'barcode' => '7890001000002', 'price_cost' => 18.00, 'price_sale' => 35.00, 'measure_unit' => 'UN', 'kit' => false, 'visible_franchisee' => true, 'weight' => 0.300, 'length' => 29.7, 'height' => 21.0, ], [ 'name' => 'Apostila Nível 3', 'sku' => 'AP-NV3', 'barcode' => '7890001000003', 'price_cost' => 18.00, 'price_sale' => 35.00, 'measure_unit' => 'UN', 'kit' => false, 'visible_franchisee' => true, 'weight' => 0.300, 'length' => 29.7, 'height' => 21.0, ], [ 'name' => 'Kit Material Didático Básico', 'sku' => 'KIT-MAT-BAS', 'barcode' => '7890001000010', 'price_cost' => 45.00, 'price_sale' => 89.90, 'measure_unit' => 'KIT', 'kit' => true, 'visible_franchisee' => true, 'weight' => 0.800, 'length' => 30.0, 'height' => 22.0, ], [ 'name' => 'Kit Material Didático Completo', 'sku' => 'KIT-MAT-COMP', 'barcode' => '7890001000011', 'price_cost' => 90.00, 'price_sale' => 169.90, 'measure_unit' => 'KIT', 'kit' => true, 'visible_franchisee' => true, 'weight' => 1.500, 'length' => 30.0, 'height' => 22.0, ], [ 'name' => 'Caderno de Atividades', 'sku' => 'CAD-ATI', 'barcode' => '7890001000020', 'price_cost' => 12.00, 'price_sale' => 24.90, 'measure_unit' => 'UN', 'kit' => false, 'visible_franchisee' => true, 'weight' => 0.200, 'length' => 29.7, 'height' => 21.0, ], [ 'name' => 'Livro do Aluno — Ginástica do Cérebro', 'sku' => 'LV-ALUNO-GC', 'barcode' => '7890001000030', 'price_cost' => 32.00, 'price_sale' => 59.90, 'measure_unit' => 'UN', 'kit' => false, 'visible_franchisee' => true, 'weight' => 0.450, 'length' => 23.0, 'height' => 16.0, ], [ 'name' => 'Camiseta Ginástica do Cérebro', 'sku' => 'CAM-GC', 'barcode' => '7890001000040', 'price_cost' => 20.00, 'price_sale' => 49.90, 'measure_unit' => 'UN', 'kit' => false, 'visible_franchisee' => true, 'weight' => 0.200, 'length' => 30.0, 'height' => 20.0, ], [ 'name' => 'Pasta do Aluno', 'sku' => 'PAST-ALUNO', 'barcode' => '7890001000050', 'price_cost' => 5.00, 'price_sale' => 12.90, 'measure_unit' => 'UN', 'kit' => false, 'visible_franchisee' => true, 'weight' => 0.100, 'length' => 33.0, 'height' => 23.0, ], [ 'name' => 'Certificado de Conclusão', 'sku' => 'CERT-CONCL', 'barcode' => '7890001000060', 'price_cost' => 2.00, 'price_sale' => 5.00, 'measure_unit' => 'UN', 'kit' => false, 'visible_franchisee' => false, 'weight' => 0.050, 'length' => 29.7, 'height' => 21.0, ], ]; foreach ($products as $product) { Product::firstOrCreate(['sku' => $product['sku']], $product); } } private function seedClassPackages(): void { $packages = [ [ 'name' => 'Plano Anual', 'quantity_classes' => 78, 'contract_value' => 1198.90, 'contract_material_value' => 299.90, 'contract_register_value' => 89.90, 'contrat_discount_value' => null, ], [ 'name' => 'Plano Mensal', 'quantity_classes' => 4, 'contract_value' => 1198.90, 'contract_material_value' => 299.90, 'contract_register_value' => 89.90, 'contrat_discount_value' => null, ], [ 'name' => 'Plano VIP', 'quantity_classes' => 4, 'contract_value' => 1198.90, 'contract_material_value' => 299.90, 'contract_register_value' => 89.90, 'contrat_discount_value' => null, ], [ 'name' => 'Plano Trimestral', 'quantity_classes' => 12, 'contract_value' => 1198.90, 'contract_material_value' => 299.90, 'contract_register_value' => 89.90, 'contrat_discount_value' => null, ], [ 'name' => 'Plano Semestral', 'quantity_classes' => 24, 'contract_value' => 1198.90, 'contract_material_value' => 299.90, 'contract_register_value' => 89.90, 'contrat_discount_value' => null, ], [ 'name' => 'Plano Lúdico', 'quantity_classes' => 24, 'contract_value' => 1198.90, 'contract_material_value' => 299.90, 'contract_register_value' => 89.90, 'contrat_discount_value' => null, ], [ 'name' => 'Plano Play', 'quantity_classes' => 78, 'contract_value' => 1198.90, 'contract_material_value' => 299.90, 'contract_register_value' => 89.90, 'contrat_discount_value' => null, ], [ 'name' => 'Plano Plus', 'quantity_classes' => 4, 'contract_value' => 1198.90, 'contract_material_value' => 299.90, 'contract_register_value' => 89.90, 'contrat_discount_value' => null, ], [ 'name' => 'Plano Mais Conhecimento', 'quantity_classes' => 4, 'contract_value' => 1198.90, 'contract_material_value' => 299.90, 'contract_register_value' => 89.90, 'contrat_discount_value' => null, ], [ 'name' => 'Plano Reforço', 'quantity_classes' => 12, 'contract_value' => 1198.90, 'contract_material_value' => 299.90, 'contract_register_value' => 89.90, 'contrat_discount_value' => null, ], [ 'name' => 'Plano Aprendiz', 'quantity_classes' => 24, 'contract_value' => 1198.90, 'contract_material_value' => 299.90, 'contract_register_value' => 89.90, 'contrat_discount_value' => null, ], [ 'name' => 'Plano Senior', 'quantity_classes' => 24, 'contract_value' => 1198.90, 'contract_material_value' => 299.90, 'contract_register_value' => 89.90, 'contrat_discount_value' => null, ], ]; foreach ($packages as $package) { ClassPackage::firstOrCreate(['name' => $package['name']], $package); } } private function seedClassPackageProducts(): void { // Base products included in every package $baseSkus = ['AP-NV1', 'CAD-ATI', 'PAST-ALUNO']; // Additional products for kit-based packages $kitSkus = ['KIT-MAT-BAS', 'LV-ALUNO-GC']; $kitPackageNames = ['Plano VIP', 'Plano Plus', 'Plano Anual', 'Plano Play']; $products = Product::whereIn('sku', array_merge($baseSkus, $kitSkus))->get()->keyBy('sku'); $packages = ClassPackage::all(); foreach ($packages as $package) { $skus = in_array($package->name, $kitPackageNames) ? array_merge($baseSkus, $kitSkus) : $baseSkus; foreach ($skus as $sku) { $product = $products->get($sku); if (!$product) { continue; } DB::table('class_package_products')->insertOrIgnore([ 'class_package_id' => $package->id, 'product_id' => $product->id, 'quantity' => 1, 'price' => $product->price_sale, 'created_at' => now(), 'updated_at' => now(), ]); } } } private function seedTestFranchisees(): void { $prState = State::where('code', 'PR')->first(); $alState = State::where('code', 'AL')->first(); $toledoCity = City::where('name', 'Toledo')->where('state_id', $prState->id)->first(); $maceioCity = City::where('name', 'Maceió')->where('state_id', $alState->id)->first(); $gabriel = User::firstOrCreate( ['email' => 'gabriel@softpar.inf.br'], [ 'name' => 'Gabriel', 'password' => 'S@ft2080.', 'user_type' => UserTypeEnum::ADMIN_FRANCHISEE, ] ); $heloisa = User::firstOrCreate( ['email' => 'heloisa@softpar.inf.br'], [ 'name' => 'Heloisa', 'password' => 'S@ft2080.', 'user_type' => UserTypeEnum::ADMIN_FRANCHISEE, ] ); $gabrielFranchisee = Franchisee::firstOrCreate( ['cpf' => '000.000.001-00'], [ 'name' => 'Gabriel (Teste)', 'street' => 'Rua Sete de Setembro', 'address_number' => '100', 'neighborhood' => 'Centro', 'postal_code' => '85900-000', 'city_id' => $toledoCity->id, 'state_id' => $prState->id, ] ); $heloisaFranchisee = Franchisee::firstOrCreate( ['cpf' => '000.000.002-00'], [ 'name' => 'Heloisa (Teste)', 'street' => 'Rua do Comércio', 'address_number' => '200', 'neighborhood' => 'Centro', 'postal_code' => '57000-000', 'city_id' => $maceioCity->id, 'state_id' => $alState->id, ] ); $gabrielUnit = Unit::firstOrCreate( ['cnpj' => '00.000.001/0001-00'], [ 'fantasy_name' => 'Unidade Gabriel (Teste)', 'social_reason' => 'Unidade Gabriel Teste LTDA', 'phone_number' => '(45) 99999-0001', 'street' => 'Rua Sete de Setembro', 'address_number' => '100', 'neighborhood' => 'Centro', 'postal_code' => '85900-000', 'city_id' => $toledoCity->id, 'state_id' => $prState->id, 'email' => 'unidade.gabriel@gc.com.br', 'name_responsible' => 'Gabriel', ] ); $heloisaUnit = Unit::firstOrCreate( ['cnpj' => '00.000.002/0001-00'], [ 'fantasy_name' => 'Unidade Heloisa (Teste)', 'social_reason' => 'Unidade Heloisa Teste LTDA', 'phone_number' => '(82) 99999-0002', 'street' => 'Rua do Comércio', 'address_number' => '200', 'neighborhood' => 'Centro', 'postal_code' => '57000-000', 'city_id' => $maceioCity->id, 'state_id' => $alState->id, 'email' => 'unidade.heloisa@gc.com.br', 'name_responsible' => 'Heloisa', ] ); // Link franchisees to units DB::table('franchisee_units')->insertOrIgnore([ [ 'franchisee_id' => $gabrielFranchisee->id, 'unit_id' => $gabrielUnit->id, 'created_at' => now(), 'updated_at' => now(), ], [ 'franchisee_id' => $heloisaFranchisee->id, 'unit_id' => $heloisaUnit->id, 'created_at' => now(), 'updated_at' => now(), ], ]); // Link users to units UnitUser::firstOrCreate(['unit_id' => $gabrielUnit->id, 'user_id' => $gabriel->id]); UnitUser::firstOrCreate(['unit_id' => $heloisaUnit->id, 'user_id' => $heloisa->id]); // Link all class packages to both test units $packageIds = ClassPackage::pluck('id'); foreach ($packageIds as $packageId) { DB::table('class_package_units')->insertOrIgnore([ [ 'class_package_id' => $packageId, 'unit_id' => $gabrielUnit->id, 'visible' => true, 'created_at' => now(), 'updated_at' => now(), ], [ 'class_package_id' => $packageId, 'unit_id' => $heloisaUnit->id, 'visible' => true, 'created_at' => now(), 'updated_at' => now(), ], ]); } } }