cms page
This commit is contained in:
parent
9e2189875f
commit
c602ab1123
|
|
@ -18,6 +18,9 @@ use Sarga\API\Http\Controllers\Banners as Slider;
|
|||
use Webkul\Core\Repositories\SliderRepository;
|
||||
use Webkul\Product\Repositories\SearchRepository;
|
||||
use Carbon\Carbon;
|
||||
use Webkul\CMS\Repositories\CmsRepository;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
|
||||
class Products extends ProductController
|
||||
{
|
||||
|
|
@ -43,6 +46,26 @@ class Products extends ProductController
|
|||
return ProductResource::collection($this->productRepository->getAll(request()->input('category')));
|
||||
}
|
||||
|
||||
public function contents(CmsRepository $cmsRepository, Request $request)
|
||||
{
|
||||
$pageUrl = $request->get('url');
|
||||
|
||||
$validation = Validator::make($request->all(), [
|
||||
'url' => 'required|string',
|
||||
]);
|
||||
|
||||
if ($validation->fails()) {
|
||||
return response()->json(['errors'=>$validation->getMessageBag()->all()],422);
|
||||
}
|
||||
|
||||
$content = $cmsRepository->findByUrlKeyOrFail($pageUrl);
|
||||
|
||||
return response([
|
||||
'data' => $content,
|
||||
'message' => 'Successfully get page'
|
||||
]);
|
||||
}
|
||||
|
||||
public function home(SliderRepository $sliderRepository,)
|
||||
{
|
||||
// $data = [
|
||||
|
|
|
|||
|
|
@ -58,6 +58,7 @@ Route::group(['prefix' => 'api'], function () {
|
|||
|
||||
Route::get('home', [Products::class, 'home']);
|
||||
Route::post('search/image', [Products::class, 'searchImg']);
|
||||
Route::post('page-content', [Products::class, 'contents']);
|
||||
|
||||
//Product routes
|
||||
Route::get('products', [Products::class, 'index']);
|
||||
|
|
|
|||
Loading…
Reference in New Issue