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);
|
||||
|
Reference in New Issue
Block a user