This repository has been archived on 2025-12-04. You can view files and clone it. You cannot open issues or pull requests or push a commit.
2025-11-18 10:27:49 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
|
|
|
|
|
|
use App\Models\LineItem;
|
|
|
|
|
use App\Support\ApiDataTransformer;
|
|
|
|
|
|
|
|
|
|
class LineItemController extends Controller
|
|
|
|
|
{
|
|
|
|
|
public function index($invoiceId)
|
|
|
|
|
{
|
2025-11-26 10:05:43 +01:00
|
|
|
$items = LineItem::with('unit')
|
|
|
|
|
->select('line_items.*')
|
2025-11-18 10:27:49 +01:00
|
|
|
->where('invoice_id', $invoiceId)
|
|
|
|
|
->orderBy('position', 'desc')
|
|
|
|
|
->get();
|
|
|
|
|
|
|
|
|
|
return $items->map(function ($item) {
|
2025-11-26 10:05:43 +01:00
|
|
|
$itemArray = $item->toArray();
|
|
|
|
|
|
|
|
|
|
if ($item->unit) {
|
|
|
|
|
$itemArray['unit_name'] = $item->unit->name;
|
|
|
|
|
$itemArray['unit_symbol'] = $item->unit->symbol;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return ApiDataTransformer::snakeToCamel($itemArray);
|
2025-11-18 10:27:49 +01:00
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|