示例#1
0
 /**
  * @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();
 }