コード例 #1
0
 public function saveComment(CommentFrontRequest $request, $productId)
 {
     $input = $request->all();
     $user = auth()->user();
     $product = $this->productRepository->findById($productId);
     $comment = new Comment();
     $comment->comment_id = isset($input['comment_id']) ? $input['comment_id'] : 0;
     $comment->storeCommentForUser(isset($input['user_to_respond']) ? $input['user_to_respond'] : $product->user->id, $user->id, $input['body'], $productId);
     try {
         $this->mailer->newCommentPublished(['email' => isset($input['author']) ? $input['author'] : $product->user->email, 'product' => $product]);
     } catch (Swift_RfcComplianceException $e) {
         Log::error($e->getMessage());
     }
     return Redirect()->route('product_path', $product->id);
 }