예제 #1
0
파일: AdController.php 프로젝트: zedx/core
 protected function syncNewAdPhotos(Ad $ad, $request, $number_pic)
 {
     $max = $ad->adtype->nbr_pic - $number_pic;
     $photoManager = new PhotoManager();
     $photos = $photoManager->save($request->file('photos'));
     $i = 0;
     foreach ($photos as $photo) {
         if ($max > $i) {
             $photo['is_main'] = $number_pic == 0 && $i == 0 ? '1' : '0';
             $ad->photos()->create($photo);
             $i++;
         }
     }
 }