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

@ -94,4 +94,16 @@ class StockController extends Controller
return response()->json(['status' => true, 'message' => 'Stock Deleted Successfully']);
}
public function getStocksByProduct(Request $request)
{
$productId = $request->product_id;
try {
$stocks = $this->stockRepository->getStocksByProduct($productId);
} catch (\Throwable $th) {
toastr()->error($th->getMessage());
}
return response()->json(['stocks' => $stocks]);
}
}

View File

@ -7,6 +7,7 @@ interface StockInterface
public function findAll();
public function getStockById($StockId);
public function getStockByEmail($email);
public function getStocksByProduct($productId);
public function delete($StockId);
public function create($StockDetails);
public function update($StockId, array $newDetails);

View File

@ -23,6 +23,11 @@ class StockRepository implements StockInterface
return Stock::where('email', $email)->first();
}
public function getStocksByProduct($productId)
{
return Stock::where('product_id', $productId)->pluck('title', 'id');
}
public function delete($StockId)
{
Stock::destroy($StockId);

View File

@ -19,5 +19,7 @@ use Modules\Stock\Http\Controllers\StockLocationController;
Route::group([], function () {
Route::resource('stock', StockController::class)->names('stock');
Route::resource('stockLocation', StockLocationController::class)->names('stockLocation');
Route::get('/stocks-by-product', [StockController::class, 'getStocksByProduct'])->name('stocks-by-product');
});