review apis
This commit is contained in:
parent
dbdf702a28
commit
38378248d2
|
|
@ -7,6 +7,7 @@ use Illuminate\Http\Request;
|
|||
use Illuminate\Http\Response;
|
||||
use Webkul\Product\Repositories\ProductRepository as Product;
|
||||
use Webkul\Product\Repositories\ProductReviewRepository as ProductReview;
|
||||
use Webkul\Product\Helpers\Review;
|
||||
use Validator;
|
||||
|
||||
/**
|
||||
|
|
@ -38,6 +39,12 @@ class ReviewController extends Controller
|
|||
*/
|
||||
protected $productReview;
|
||||
|
||||
/**
|
||||
* Review helper Object
|
||||
*
|
||||
*/
|
||||
protected $reviewHelper;
|
||||
|
||||
/**
|
||||
* Create a new controller instance.
|
||||
*
|
||||
|
|
@ -45,7 +52,7 @@ class ReviewController extends Controller
|
|||
* @param Webkul\Product\Repositories\ProductReviewRepository $productReview
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(Product $product, ProductReview $productReview)
|
||||
public function __construct(Product $product, ProductReview $productReview, Review $reviewHelper)
|
||||
{
|
||||
// $this->middleware('customer')->only(['create', 'store', 'destroy']);
|
||||
|
||||
|
|
@ -53,6 +60,8 @@ class ReviewController extends Controller
|
|||
|
||||
$this->productReview = $productReview;
|
||||
|
||||
$this->reviewHelper = $reviewHelper;
|
||||
|
||||
$this->_config = request('_config');
|
||||
}
|
||||
|
||||
|
|
@ -97,7 +106,9 @@ class ReviewController extends Controller
|
|||
{
|
||||
$product = $this->product->findBySlugOrFail($slug);
|
||||
|
||||
return view($this->_config['view'],compact('product'));
|
||||
$productReviews = $this->reviewHelper->getReviews($product)->get();
|
||||
|
||||
return $productReviews;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -56,19 +56,16 @@ Route::group(['namespace' => 'Webkul\API\Http\Controllers\Product', 'prefix' =>
|
|||
//product
|
||||
//to get all products
|
||||
Route::get('get/all', 'ProductController@getAll');
|
||||
|
||||
//to fetch the new products
|
||||
Route::get('get/new', 'ProductController@getNew');
|
||||
|
||||
//to fetch the featured product
|
||||
Route::get('get/featured', 'ProductController@getFeatured');
|
||||
|
||||
//to get the product by its slug
|
||||
Route::get('get/{slug}', 'ProductController@getBySlug');
|
||||
|
||||
//product reviews get and create
|
||||
//to get the reviews of the product
|
||||
Route::get('review/{slug}', 'ReviewController@show');
|
||||
|
||||
//to store the review for a product
|
||||
Route::post('review/{slug}', 'ReviewController@create');
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in New Issue