Beispiel #1
0
 public function getUrl()
 {
     $gallery = Gallery::find($this->gallery_id);
     return url($this->hasPrepend() . 'gallery_assets/galleries', [$gallery->slug, $this->file]);
 }
Beispiel #2
0
 /**
  * Handles the upload file, saves to db and return data to the response.
  *
  * @param Request $request
  * @return bool|string
  */
 public function postUpload(Request $request)
 {
     $gallery = Gallery::find($request['gallery_id']);
     $lastPosition = Photos::filterByGallery($gallery->id)->max('position');
     if ($gallery) {
         $file = PhotoUploadFacade::photoUpload($request['file'], $gallery->slug);
         if ($file) {
             $data = ['file' => $file, 'position' => $lastPosition != 0 ? $lastPosition + 1 : 0, 'state' => 1, 'gallery_id' => $gallery->id];
             $photo = Photos::create($data);
             return json_encode(['id' => $photo->id, 'file' => $photo->getUrl(), 'delete_url' => url('admin/galleries/photo/' . $photo->id)]);
         }
     }
     return false;
 }