latest()->paginate(5); } /** * Store a newly created resource in storage. * * @param int $productId * @param StoreReviewRequest $request * * @return Response */ public function store($productId, StoreReviewRequest $request) { if (!setting('reviews_enabled')) { return; } return Product::findOrFail($productId) ->reviews() ->create([ 'reviewer_id' => auth()->id(), 'rating' => $request->rating, 'reviewer_name' => $request->reviewer_name, 'comment' => $request->comment, 'is_approved' => setting('auto_approve_reviews', 0), ]); } }