Make sorting of invoice items reliable.
Some checks failed
Build project image / Build-and-release-image (push) Failing after 3m1s
Some checks failed
Build project image / Build-and-release-image (push) Failing after 3m1s
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -104,7 +104,7 @@ class Invoice extends Model
|
||||
*/
|
||||
public function items(): HasMany
|
||||
{
|
||||
return $this->hasMany(Invoiceitem::class);
|
||||
return $this->hasMany(Invoiceitem::class)->orderBy('sort');
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -22,6 +22,7 @@ class Invoiceitem extends Model
|
||||
'total',
|
||||
'name',
|
||||
'description',
|
||||
'sort'
|
||||
];
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user