public function handle(ReviewCreated $reviewCreated)
 {
     $review = $reviewCreated->getReview();
     $this->reviewManager->refreshRating($review);
     $notifiable = $review->getReviewable();
     if ($notifiable instanceof Product) {
         $notifiable = $notifiable->getSeller();
     }
     $notifiable->notify(new NewReviewNotification($review));
 }
 public function show(Order $order, ReviewManager $reviewManager)
 {
     $items = $this->orderManager->getOrderItemRepository()->whereOrder($order)->findAll();
     $reviews = $reviewManager->getReviewRepository()->whereOrder($order)->scopes('on', Product::class)->findAll()->keyBy('reviewable_id');
     // associate each item with product review if exists
     $items->map(function ($item) use($reviews) {
         if ($reviews->has($item->id)) {
             $item->review = $reviews->get($item->product_id);
         }
         return $item;
     });
     return $this->view('order::{account}.orders.show', compact('order', 'items'));
 }
 public function store(ReviewRequest $request, Order $order, Reviewable $reviewable, ReviewManager $reviewManager)
 {
     $this->authorize('create', [Review::class, $order, $reviewable]);
     $reviewManager->createReview($order, $this->account(), $reviewable, $request->all());
     return $this->success('add');
 }
 public function store(ReviewReplyRequest $request, Review $review, ReviewManager $reviewManager)
 {
     $reviewManager->createReviewReply($review, $request->all());
     return $this->success();
 }