draft ::with() function for models

This commit is contained in:
Dennis Eichhorn 2021-03-11 21:23:41 +01:00
parent 889790feb3
commit 5733eb368f
2 changed files with 10 additions and 10 deletions

View File

@ -184,7 +184,7 @@ final class ApiController extends Controller
return $element;
}
$item = ItemMapper::withConditional('language', $response->getLanguage())::get($element->item);
$item = ItemMapper::with('language', $response->getLanguage())::get($element->item);
// @todo: which item name should be stored in the database? server language (problem for international company with subsidiaries)? customer default language/customer invoice language?
$element->itemNumber = $item->number;
$element->itemName = $item->getL11n('name1')->description;

View File

@ -53,17 +53,17 @@ final class BackendController extends Controller
if ($request->getData('ptype') === 'p') {
$view->setData('bills',
SalesBillMapper::withConditional('language', $response->getLanguage(), [BillTypeL11n::class])
SalesBillMapper::with('language', $response->getLanguage(), [BillTypeL11n::class])
::getSalesBeforePivot((int) ($request->getData('id') ?? 0), limit: 25, depth: 3)
);
} elseif ($request->getData('ptype') === 'n') {
$view->setData('bills',
SalesBillMapper::withConditional('language', $response->getLanguage(), [BillTypeL11n::class])
SalesBillMapper::with('language', $response->getLanguage(), [BillTypeL11n::class])
::getSalesAfterPivot((int) ($request->getData('id') ?? 0), limit: 25, depth: 3)
);
} else {
$view->setData('bills',
SalesBillMapper::withConditional('language', $response->getLanguage(), [BillTypeL11n::class])
SalesBillMapper::with('language', $response->getLanguage(), [BillTypeL11n::class])
::getSalesAfterPivot(0, limit: 25, depth: 3)
);
}
@ -137,17 +137,17 @@ final class BackendController extends Controller
if ($request->getData('ptype') === 'p') {
$view->setData('bills',
PurchaseBillMapper::withConditional('language', $response->getLanguage(), [BillTypeL11n::class])
PurchaseBillMapper::with('language', $response->getLanguage(), [BillTypeL11n::class])
::getPurchaseBeforePivot((int) ($request->getData('id') ?? 0), limit: 25, depth: 3)
);
} elseif ($request->getData('ptype') === 'n') {
$view->setData('bills',
PurchaseBillMapper::withConditional('language', $response->getLanguage(), [BillTypeL11n::class])
PurchaseBillMapper::with('language', $response->getLanguage(), [BillTypeL11n::class])
::getPurchaseAfterPivot((int) ($request->getData('id') ?? 0), limit: 25, depth: 3)
);
} else {
$view->setData('bills',
PurchaseBillMapper::withConditional('language', $response->getLanguage(), [BillTypeL11n::class])
PurchaseBillMapper::with('language', $response->getLanguage(), [BillTypeL11n::class])
::getPurchaseAfterPivot(0, limit: 25, depth: 3)
);
}
@ -200,17 +200,17 @@ final class BackendController extends Controller
if ($request->getData('ptype') === 'p') {
$view->setData('bills',
StockBillMapper::withConditional('language', $response->getLanguage(), [BillTypeL11n::class])
StockBillMapper::with('language', $response->getLanguage(), [BillTypeL11n::class])
::getStockBeforePivot((int) ($request->getData('id') ?? 0), limit: 25, depth: 3)
);
} elseif ($request->getData('ptype') === 'n') {
$view->setData('bills',
StockBillMapper::withConditional('language', $response->getLanguage(), [BillTypeL11n::class])
StockBillMapper::with('language', $response->getLanguage(), [BillTypeL11n::class])
::getStockAfterPivot((int) ($request->getData('id') ?? 0), limit: 25, depth: 3)
);
} else {
$view->setData('bills',
StockBillMapper::withConditional('language', $response->getLanguage(), [BillTypeL11n::class])
StockBillMapper::with('language', $response->getLanguage(), [BillTypeL11n::class])
::getStockAfterPivot(0, limit: 25, depth: 3)
);
}