/** * @param $Album * @param $AlbumCategory * @internal param $catsAlbum */ private function createPhotos($Album, $AlbumCategory) { $photosCount = $this->faker->numberBetween($min = 15, $max = 30); $output = new \Symfony\Component\Console\Output\ConsoleOutput(); $progress = new ProgressBar($output, $photosCount); for ($x = 0; $x <= $photosCount; $x++) { list($dimensionX, $dimensionY) = $this->faker->randomElement([[1920, 1200], [1920, 1080], [1600, 1200], [1280, 1024], [1280, 800], [960, 720]]); $photo = Photo::create(['album_id' => $Album->id, 'title' => $this->faker->words(6, true), 'caption' => $this->faker->sentence(), 'captured_at' => \Carbon\Carbon::now(), 'height' => $dimensionY, 'width' => $dimensionX]); $image = $this->faker->image('/tmp', $dimensionX, $dimensionY, strtolower($AlbumCategory)); $photo->addMedia($image)->toCollection('images'); $progress->advance(); } $progress->finish(); }
public function transform(Photo $photo) { return ['id' => (int) $photo->id, 'title' => $photo->title, 'caption' => $photo->caption, 'image' => $photo->getFirstMediaUrl('images'), 'thumbnail' => ['square' => $photo->getFirstMediaUrl('images', 'thumbnail-square'), 'small' => $photo->getFirstMediaUrl('images', 'thumbnail-small'), 'medium' => $photo->getFirstMediaUrl('images', 'thumbnail-medium'), 'large' => $photo->getFirstMediaUrl('images', 'thumbnail-large')], 'properties' => ['filename' => $photo->getFirstMedia('images') ? $photo->getFirstMedia('images')->file_name : null, 'filesize' => $photo->filesize, 'height' => $photo->height, 'width' => $photo->width, 'uploaded_on' => $photo->created_at->toDateTimeString(), 'modified_on' => $photo->updated_at->toDateTimeString(), 'captured_on' => $photo->captured_at->toDateTimeString()]]; }