13-05-2026 Waren Wirtschaft
This commit is contained in:
parent
9ce711d6b2
commit
ca3eb663fe
40 changed files with 1000 additions and 189 deletions
|
|
@ -11,7 +11,28 @@ class PackagingItemRepository
|
|||
*/
|
||||
public function create(array $data): PackagingItem
|
||||
{
|
||||
return PackagingItem::create($this->extractAttributes($data));
|
||||
$attrs = $this->extractAttributes($data);
|
||||
\DB::enableQueryLog();
|
||||
|
||||
try {
|
||||
$item = PackagingItem::create($attrs);
|
||||
} catch (\Throwable $e) {
|
||||
$queries = \DB::getQueryLog();
|
||||
$lastQ = end($queries);
|
||||
\Log::error('PackagingItem CREATE FAILED', [
|
||||
'error' => $e->getMessage(),
|
||||
'sql' => $lastQ['query'] ?? 'unknown',
|
||||
'bindings' => $lastQ['bindings'] ?? [],
|
||||
'binding_types' => array_map(fn($v) => gettype($v) . ':' . json_encode($v), $lastQ['bindings'] ?? []),
|
||||
'attributes_passed' => $attrs,
|
||||
]);
|
||||
|
||||
throw $e;
|
||||
}
|
||||
|
||||
\DB::disableQueryLog();
|
||||
|
||||
return $item;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -30,15 +51,20 @@ class PackagingItemRepository
|
|||
*/
|
||||
protected function extractAttributes(array $data): array
|
||||
{
|
||||
return collect($data)->only([
|
||||
$attrs = collect($data)->only([
|
||||
'packaging_material_id',
|
||||
'supplier_id',
|
||||
'name',
|
||||
'category',
|
||||
'weight_grams',
|
||||
'min_stock_alert',
|
||||
'url',
|
||||
'product_id',
|
||||
'active',
|
||||
])->all();
|
||||
|
||||
$attrs['weight_grams'] = $attrs['weight_grams'] ?? 0;
|
||||
|
||||
return $attrs;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue