Beispiel #1
0
 /**
  * change a picture to become the main picture
  *
  * @param $id
  *
  * @return \Illuminate\Http\JsonResponse
  */
 public function setMainPicture($id)
 {
     $photo = $this->photo->find($id);
     //$this->photo = Photo::where('id', $id)->get()->first();
     Helper::allow('photo-edit', $photo->album);
     $this->photo->update(['main_picture' => 0], $photo->album->id, 'album_id');
     $this->photo->update(['main_picture' => 1], $id);
     return response()->json(['success']);
 }
 /**
  * Display the specified resource.
  *
  * @param $id
  * @return Response
  */
 public function show($id)
 {
     $product = $this->productRepository->publishedOrSelledById($id);
     $comments = $product->comments()->where('comment_id', '=', 0)->paginate(5);
     $photos = $this->photoRepository->getPhotos($product->id);
     if (Auth()->user()) {
         $commentsNotViewed = $product->comments()->notViewed()->where('user_id', '=', Auth()->user()->id)->get();
         foreach ($commentsNotViewed as $comment) {
             $comment->viewed = true;
             $comment->save();
         }
     }
     return view('products.show')->with(compact('product', 'photos', 'comments'));
 }
 /**
  * Remove the specified resource from storage.
  * DELETE /photos/{id}
  *
  * @param  int $id
  * @return Response
  */
 public function destroy($id)
 {
     return $this->photoRepository->destroy($id);
 }