Erster Upload
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\User\Resources\ProductResource\Pages;
|
||||
|
||||
use App\Filament\User\Resources\ProductResource;
|
||||
use Filament\Resources\Pages\CreateRecord;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use App\Models\ProductSize;
|
||||
|
||||
class CreateProduct extends CreateRecord
|
||||
{
|
||||
protected static string $resource = ProductResource::class;
|
||||
|
||||
protected function handleRecordCreation(array $data): Model {
|
||||
|
||||
$record = static::getModel()::create($data);
|
||||
|
||||
foreach ($data['sizes'] as $size) {
|
||||
ProductSize::create([
|
||||
'product_id' => $record->id,
|
||||
'packing_id' => $size['packing_id'],
|
||||
'description' => $size['description'],
|
||||
'price' => $size['price'],
|
||||
]);
|
||||
}
|
||||
return $record;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user