1, 'tv' => 2, 'mobile' => 3, 'food' => 4, 'subscription' => 5, 'electronic' => 6 ]; if ($productTypes !== null && is_string($productTypes)) { $productTypes = explode(",", $productTypes); } else { $productTypes = $predefinedTypes; } $arrayKeys = Arr::isAssoc($productTypes) ? array_keys($productTypes) : $productTypes; $generatableTypes = Arr::only($predefinedTypes, $arrayKeys); $randomNumber = $predefinedTypes[array_rand(($generatableTypes))]; if ($randomNumber === 1) { return [ 'name' => static::generateClothName(), 'variationType' => 'cloth', 'payment_type' => 'onetime', ]; //return static::generateClothName().'+'.'cloth'; } if ($randomNumber === 2) { return [ 'name' => static::generateTvName(), 'variationType' => 'tv', 'payment_type' => 'onetime', ]; } if ($randomNumber === 3) { return [ 'name' => static::generateMobileName(), 'variationType' => 'mobile', 'payment_type' => 'onetime', ]; } if ($randomNumber === 4) { return [ 'name' => static::generateFoodName(), 'variationType' => 'food', 'payment_type' => 'onetime', ]; } if ($randomNumber === 5) { return [ 'name' => static::generateSubscriptionName(), 'variationType' => 'subscribable', 'payment_type' => 'subscription', ]; } else return [ 'name' => static::generateElectronicProductName(), 'variationType' => 'electronic', 'payment_type' => 'onetime', ]; } public function productVariation($type, $productTitle, $paymentType, $index): string { if ($type === 'cloth') { return static::generateClothVariation(); } if ($type === 'tv') { return static::generateTvVariation(); } if ($type === 'mobile') { return static::generateMobileVariation(); } if ($type === 'food') { return static::generateFoodVariation(); } if ($type === 'subscribable') { return static::generateSubscribableVariation($productTitle, $paymentType, $index); } else return static::generateElectronicProductVariation(); } public static function generateSubscribableVariation($productTitle, $paymentType, $index): string { $prefixes = ['Lifetime', 'Weekly', "Monthly", "Yearly"]; return Arr::get($prefixes, $index, 'Lifetime') . " " . $productTitle; // if ($paymentType === 'onetime') { // return "Lifetime $productTitle"; // } else { // $prefixes = ['Weekly', "Monthly", "Yearly"]; // // return $prefixes[array_rand($prefixes)] . " " . $productTitle; // } } public static function generateClothVariation(): string { $fabric = array('Cotton', 'Polyester', 'Silk', 'Wool', 'Linen', 'Velvet', 'Satin', 'Chiffon'); $size = array('Small', 'Medium', 'Large', 'Extra-large', 'Plus sizes'); $fabric = $fabric[array_rand($fabric)]; $size = $size[array_rand($size)]; return $fabric . ' ' . $size; } public function generateTvVariation(): string { $type = array("LED", "OLED", "QLED", "LCD", "Plasma", "Curved screens"); $size = array("32 inches", "40 inches", "55 inches", "65 inches", "75 inches", "85 inches"); $resolution = array("HD (720p)", "Full HD (1080p)", "4K Ultra HD (2160p)", "8K Ultra HD (4320p)"); $type = $type[array_rand($type)]; $size = $size[array_rand($size)]; $resolution = $resolution[array_rand($resolution)]; return $type . ' ' . $size . ' ' . $resolution; } public static function generateMobileVariation(): string { $size = ["Small (below 5 inches)", "Standard (5 to 6 inches)", "Large (above 6 inches)"]; $storageCapacity = ["64GB", "128GB", "256GB", "512GB"]; $cameraCapabilities = ["Single-camera", "Dual-camera", "Triple-camera", "Quad-camera", "Front camera resolution"]; $size = $size[array_rand($size)]; $storageCapacity = $storageCapacity[array_rand($storageCapacity)]; $cameraCapabilities = $cameraCapabilities[array_rand($cameraCapabilities)]; return $size . ' ' . $storageCapacity . ' ' . $cameraCapabilities; } public static function generateFoodVariation(): string { $cuisine = ["Italian", "Chinese", "Indian", "Mexican", "Japanese", "Thai", "American", "French", "Mediterranean", "Middle Eastern"]; $category = ["Snacks", "Beverages", "Dairy products", "Meat and poultry", "Fruits and vegetables"]; $preference = ["Vegan", "Vegetarian", "Gluten-free", "Organic", "Halal", "Kosher"]; $flavor = ["Sweet", "Salty", "Spicy", "Sour", "Bitter", "Umami"]; $packagingSize = ["Family packs", "Individual servings", "Economy size", "Travel-size packs"]; $cuisine = $cuisine[array_rand($cuisine)]; $category = $category[array_rand($category)]; $preference = $preference[array_rand($preference)]; $flavor = $flavor[array_rand($flavor)]; $packagingSize = $packagingSize[array_rand($packagingSize)]; return $cuisine . ' ' . $category . ' ' . $preference . ' ' . $flavor . ' ' . $packagingSize; } public static function generateElectronicProductVariation(): string { $displaySize = ["11-inch", "13-inch", "15-inch", "17-inch", "24-inch", "32-inch", "40-inch", "55-inch", "65-inch", "75-inch"]; $screenResolution = ["HD (720p)", "Full HD (1080p)", "4K Ultra HD (2160p)", "8K Ultra HD (4320p)"]; $memory = ["4GB", "8GB", "16GB", "32GB", "64GB", "128GB", "256GB", "512GB", "1TB", "2TB"]; $cameraResolution = ["12MP", "16MP", "20MP", "24MP", "32MP", "48MP", "64MP", "108MP"]; $batteryLife = ["8 hours", "10 hours", "12 hours", "24 hours"]; $displaySize = $displaySize[array_rand($displaySize)]; $screenResolution = $screenResolution[array_rand($screenResolution)]; $memory = $memory[array_rand($memory)]; $cameraResolution = $cameraResolution[array_rand($cameraResolution)]; $batteryLife = $batteryLife[array_rand($batteryLife)]; return $displaySize . ' ' . $screenResolution . ' ' . $memory . ' ' . $cameraResolution . ' Battery - Up to ' . $batteryLife; } public static function productSignUpFeeName(): string { $feeNames = array( 'QuickStart', 'SwiftSetup', 'RapidCharge', 'TurboInstall', 'SnapSetup', 'BlitzCharge', 'FastTrack', 'InstaCharge', 'EasyStart', 'SpeedySetup', 'LightningCharge', 'PromptInstall', 'ExpressSetup', 'FlashCharge', 'SimpleStart' ); return $feeNames[array_rand($feeNames)]; } }