'Single offer', 'description' => 'Selected offer' ]; } public function defineProperties() { return [ 'productSlug' => [ 'title' => 'Product slug', 'description' => 'Product slug', 'type' => 'string', 'default' => '{{ :slug }}' ], 'offerId' => [ 'title' => 'Offer id', 'description' => 'Offer id', 'type' => 'string', 'default' => '{{ :id }}' ] ]; } public function onCommentSave(){ $data = post(); $comment = new Comment; $comment->user_id = \Auth::user()->id; $comment->product_id = $data["product_id"]; $comment->rating = $data["star"]; $comment->comment = $data["comment"]; $comment->save(); Flash::success("Teswir goshuldy"); } public function onRun() { $this->offer = $this->loadOffer(); } protected function loadOffer() { $product = Product::withCount("comments")->find($this->property('offerId')); if($product && $product->status == 'approved') { $product->number_of_views = $product->number_of_views + 1; $product->save(); return $product; } return null; } public $offer; }