Beispiel #1
0
 /**
  * @param $id
  * @param Manager $fractal
  * @param ImageTransformer $imageTransformer
  * @return mixed
  */
 public function show($id, Manager $fractal, ImageTransformer $imageTransformer)
 {
     $project = $this->image->find($id);
     if (!$project) {
         return Response::json(['error' => ['message' => 'Imagem não foi encontrado, favor procurar outro nome']], 404);
     }
     $item = new Item($project, $imageTransformer);
     $data = $fractal->createData($item)->toArray();
     return $this->respond($data);
 }
 /**
  * @param Image $camisetaImage
  * @param $id
  * @return \Illuminate\Http\RedirectResponse
  */
 public function destroyImage(Image $camisetaImage, $id)
 {
     $image = $camisetaImage->find($id);
     if (file_exists('/uploads/' . $image->id . '.' . $image->extension)) {
         Storage::disk('public_local')->delete($image->id . '.' . $image->extension);
     }
     $camiseta = $image->product;
     $image->delete();
     return redirect()->route('products.images', ['id' => $camiseta->id]);
 }