Add products module #46
This commit is contained in:
@@ -9,13 +9,21 @@ class LineItemController extends Controller
|
||||
{
|
||||
public function index($invoiceId)
|
||||
{
|
||||
$items = LineItem::select()
|
||||
$items = LineItem::with('unit')
|
||||
->select('line_items.*')
|
||||
->where('invoice_id', $invoiceId)
|
||||
->orderBy('position', 'desc')
|
||||
->get();
|
||||
|
||||
return $items->map(function ($item) {
|
||||
return ApiDataTransformer::snakeToCamel($item->toArray());
|
||||
$itemArray = $item->toArray();
|
||||
|
||||
if ($item->unit) {
|
||||
$itemArray['unit_name'] = $item->unit->name;
|
||||
$itemArray['unit_symbol'] = $item->unit->symbol;
|
||||
}
|
||||
|
||||
return ApiDataTransformer::snakeToCamel($itemArray);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user