*/ class PlanFactory extends Factory { /** * Define the model's default state. * * @return array */ public function definition(): array { $faker = \Faker\Factory::create(); $this->faker->addProvider(new Restaurant($faker)); $active = $this->faker->boolean(); $typeBody = [ 'fit' => $this->faker->boolean(), 'slim' => $this->faker->boolean(), 'behavior' => $this->faker->boolean(), 'wellness' => $this->faker->boolean(), ]; $wrongTypeBody = json_encode($typeBody); $packetsOptions1 = [ 'items' => [$this->faker->fruitName(), $this->faker->meatName(), $this->faker->sauceName()], 'price' => $this->faker->randomNumber(), 'short' => $this->faker->foodName(), 'description' => $this->faker->text(), ]; $packetsOptions2 = [ 'items' => [$this->faker->fruitName(), $this->faker->meatName(), $this->faker->sauceName()], 'price' => $this->faker->randomNumber(), 'short' => $this->faker->foodName(), 'description' => $this->faker->text(), ]; $packetsOptions3 = [ 'items' => [$this->faker->fruitName(), $this->faker->meatName(), $this->faker->sauceName()], 'price' => $this->faker->randomNumber(), 'short' => $this->faker->foodName(), 'description' => $this->faker->text(), ]; Storage::fake('plans'); $file = UploadedFile::fake()->image('plan.png'); $fileLocalPath = $file->store('plans', 'public'); return [ 'name' => $this->faker->foodName(), // 'image' => UploadedFile::fake()->image('plans/Photo_C.png'), 'image' => $fileLocalPath, 'duration' => $this->faker->randomElement([7, 14, 21]), 'state' => $this->faker->randomElement(['active', 'draft', 'unactive']), //'type' => $this->faker->randomElement([$typeBody, $wrongTypeBody]), 'type' => $typeBody, 'details' => $this->faker->text(), 'packets_count' => $active ? 3 : 1, 'packet1_options' => $packetsOptions1, 'packet2_options' => $active ? $packetsOptions2 : '', 'packet3_options' => $active ? $packetsOptions3 : '', ]; } }