Make sorting of invoice items reliable.
Some checks failed
Build project image / Build-and-release-image (push) Failing after 3m1s

This commit is contained in:
2025-08-02 12:12:57 +02:00
parent e1f579c7fd
commit 0a4089fe14
6 changed files with 33 additions and 2 deletions

View File

@@ -32,7 +32,7 @@ class InvoiceitemController extends Controller
'name' => 'required|string',
'description' => 'nullable|string',
'article_number' => 'nullable|string',
'sort' => 'required|numeric|min:0',
]);
$item = $invoice->items()->create($itemData);

View File

@@ -104,7 +104,7 @@ class Invoice extends Model
*/
public function items(): HasMany
{
return $this->hasMany(Invoiceitem::class);
return $this->hasMany(Invoiceitem::class)->orderBy('sort');
}
/**

View File

@@ -22,6 +22,7 @@ class Invoiceitem extends Model
'total',
'name',
'description',
'sort'
];
}