April 2026 waren Wirtschaft Feedback
This commit is contained in:
parent
02f2a4c23e
commit
9ce711d6b2
167 changed files with 25278 additions and 8518 deletions
44
app/Repositories/PackagingItemRepository.php
Normal file
44
app/Repositories/PackagingItemRepository.php
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
<?php
|
||||
|
||||
namespace App\Repositories;
|
||||
|
||||
use App\Models\PackagingItem;
|
||||
|
||||
class PackagingItemRepository
|
||||
{
|
||||
/**
|
||||
* @param array<string, mixed> $data
|
||||
*/
|
||||
public function create(array $data): PackagingItem
|
||||
{
|
||||
return PackagingItem::create($this->extractAttributes($data));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string, mixed> $data
|
||||
*/
|
||||
public function update(PackagingItem $packagingItem, array $data): PackagingItem
|
||||
{
|
||||
$packagingItem->update($this->extractAttributes($data));
|
||||
|
||||
return $packagingItem->fresh();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string, mixed> $data
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
protected function extractAttributes(array $data): array
|
||||
{
|
||||
return collect($data)->only([
|
||||
'packaging_material_id',
|
||||
'supplier_id',
|
||||
'name',
|
||||
'category',
|
||||
'weight_grams',
|
||||
'min_stock_alert',
|
||||
'product_id',
|
||||
'active',
|
||||
])->all();
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue