feat:material
This commit is contained in:
@@ -31,6 +31,7 @@ class MaterialService extends BaseService{
|
||||
{
|
||||
$limit = (int)$this->request->input('limit', 10);
|
||||
$name = $this->request->input('query_name');
|
||||
$kitchenId = $this->request->input('query_kitchen_id');
|
||||
|
||||
$list = $this
|
||||
->MaterialModel
|
||||
@@ -39,6 +40,9 @@ class MaterialService extends BaseService{
|
||||
->when(!empty($name), function ($query) use ($name) {
|
||||
$query->where('name', 'like', "$name%");
|
||||
})
|
||||
->when(!empty($kitchenId), function ($query) use ($kitchenId) {
|
||||
$query->where('kitchen_id', $kitchenId);
|
||||
})
|
||||
->paginate($limit)->toArray();
|
||||
|
||||
return $this->return->success('success',$list);
|
||||
@@ -110,6 +114,7 @@ class MaterialService extends BaseService{
|
||||
$name = $this->request->input('query_name');
|
||||
$depotId = (int)$this->request->input('query_depotId');
|
||||
$supplierId = (int)$this->request->input('query_supplierId');
|
||||
$kitchenId = (int)$this->request->input('query_kitchenId');
|
||||
$list = $this->MaterialStockModel
|
||||
->leftJoin('material', 'material_stock.material_id', '=', 'material.id')
|
||||
->leftJoin('supplier', 'material_stock.supplier_id', '=', 'supplier.id')
|
||||
@@ -124,6 +129,9 @@ class MaterialService extends BaseService{
|
||||
->when(!empty($supplierId), function ($query) use ($supplierId) {
|
||||
$query->where('material_stock.supplier_id', $supplierId);
|
||||
})
|
||||
->when(!empty($kitchenId), function ($query) use ($kitchenId) {
|
||||
$query->where('material.kitchen_id', $kitchenId);
|
||||
})
|
||||
->paginate($limit,['material_stock.*','material.name as material_name','supplier.name as supplier_name','depot.name as depot_name'])
|
||||
->toArray();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user