*/ public function definition(): array { return [ 'name' => $this->faker->words(4, true), 'description' => $this->faker->text(), 'excerpt' => $this->faker->words(10, true), 'config' => ['sections' => []], 'from' => $this->faker->dateTime()->format('Y-m-d H:i:s'), 'to' => $this->faker->dateTime()->format('Y-m-d H:i:s'), 'registration_from' => $this->faker->dateTime()->format('Y-m-d H:i:s'), 'registration_until' => $this->faker->dateTime()->format('Y-m-d H:i:s'), 'mail_top' => $this->faker->text(), 'mail_bottom' => $this->faker->text(), 'header_image' => $this->getHeaderImagePayload(str()->uuid() . '.jpg') ]; } /** * @param array $sections */ public function sections(array $sections): self { return $this->state(['config.sections' => $sections]); } /** * @param mixed $args */ public function __call(string $method, $args): self { return $this->state([str($method)->snake()->toString() => $args[0]]); } public function headerImage(string $fileName): self { UploadedFile::fake()->image($fileName, 1000, 1000)->storeAs('media-library', $fileName, 'temp'); Storage::disk('temp')->assertExists('media-library/' . $fileName); return $this->state([ 'header_image' => $this->getHeaderImagePayload($fileName) ]); } /** * @return array */ private function getHeaderImagePayload(string $fileName): array { UploadedFile::fake()->image($fileName, 1000, 1000)->storeAs('media-library', $fileName, 'temp'); Storage::disk('temp')->assertExists('media-library/' . $fileName); return [ 'file_name' => $fileName, 'collection_name' => 'headerImage', ]; } }