salesentry filters
This commit is contained in:
@ -148,4 +148,17 @@ class ProductController extends Controller
|
||||
'data' => $productModel,
|
||||
]);
|
||||
}
|
||||
|
||||
public function getProductsByCategory(Request $request)
|
||||
{
|
||||
$categoryId = $request->category_id;
|
||||
try {
|
||||
$products = $this->productRepository->getProductsByCategory($categoryId);
|
||||
} catch (\Throwable $th) {
|
||||
toastr()->error($th->getMessage());
|
||||
}
|
||||
return response()->json(['products' => $products]);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -7,6 +7,7 @@ interface ProductInterface
|
||||
public function findAll();
|
||||
public function getProductById($ProductId);
|
||||
public function getProductByEmail($email);
|
||||
public function getProductsByCategory($categoryId);
|
||||
public function delete($ProductId);
|
||||
public function create($ProductDetails);
|
||||
public function update($ProductId, array $newDetails);
|
||||
|
@ -23,6 +23,11 @@ class ProductRepository implements ProductInterface
|
||||
return Product::where('email', $email)->first();
|
||||
}
|
||||
|
||||
public function getProductsByCategory($categoryId)
|
||||
{
|
||||
return Product::where('category_id', $categoryId)->pluck('name', 'id');
|
||||
}
|
||||
|
||||
public function delete($ProductId)
|
||||
{
|
||||
Product::destroy($ProductId);
|
||||
|
@ -25,12 +25,12 @@
|
||||
|
||||
<div class="col-md-12">
|
||||
{{ html()->label('Description')->class('form-label') }}
|
||||
{{ html()->textarea('desc')->class('form-control')->placeholder('Enter Description')->required() }}
|
||||
{{ html()->textarea('desc')->class('form-control')->placeholder('Enter Description') }}
|
||||
</div>
|
||||
|
||||
<div class="col-md-12">
|
||||
{{ html()->label('Remarks')->class('form-label') }}
|
||||
{{ html()->textarea('remarks')->class('form-control')->placeholder('Enter Remarks')->required() }}
|
||||
{{ html()->textarea('remarks')->class('form-control')->placeholder('Enter Remarks') }}
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
@ -26,6 +26,6 @@ Route::group([], function () {
|
||||
Route::resource('fabricCategory', FabricCategoryController::class)->names('fabricCategory');
|
||||
Route::get('get-sub-categories', [SubCategoryController::class, 'getSubCategories'])->name('getSubCategories');
|
||||
Route::get('product-details', [ProductController::class, 'getProductDetail'])->name('get-product-detail');
|
||||
|
||||
Route::get('/products-by-category', [ProductController::class, 'getProductsByCategory'])->name('products-by-category');
|
||||
|
||||
});
|
||||
|
Reference in New Issue
Block a user