salesentry filters

This commit is contained in:
Sampanna Rimal
2024-09-17 16:34:40 +05:45
parent afb2c202d6
commit 0b438e302d
19 changed files with 303 additions and 50 deletions

View File

@ -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]);
}
}

View File

@ -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);

View File

@ -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);

View File

@ -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>

View File

@ -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');
});