salesentry filters
This commit is contained in:
@ -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]);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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');
|
||||
|
||||
|
||||
});
|
||||
|
Reference in New Issue
Block a user