d2d.emegrendeles.hu/app/Filament/Resources/ProfitCenterSupplierSchedules/Pages/CreateProfitCenterSupplierSchedule.php
2026-07-16 08:53:09 +02:00

36 lines
1.1 KiB
PHP

<?php
namespace App\Filament\Resources\ProfitCenterSupplierSchedules\Pages;
use App\Filament\Resources\ProfitCenterSupplierSchedules\ProfitCenterSupplierScheduleResource;
use App\Models\ProfitCenterSupplierSchedule;
use Filament\Resources\Pages\CreateRecord;
use Illuminate\Database\Eloquent\Model;
class CreateProfitCenterSupplierSchedule extends CreateRecord
{
protected static string $resource = ProfitCenterSupplierScheduleResource::class;
/**
* Több profit center esetén minden egyes profit centerhez külön rekordot hoz létre.
*
* @param array<string, mixed> $data
*/
protected function handleRecordCreation(array $data): Model
{
$profitCenterIds = (array) $data['profit_center_id'];
$lastRecord = null;
foreach ($profitCenterIds as $profitCenterId) {
$lastRecord = ProfitCenterSupplierSchedule::create([
'profit_center_id' => $profitCenterId,
'supplier_id' => $data['supplier_id'],
'delivery_schedule_id' => $data['delivery_schedule_id'],
]);
}
return $lastRecord;
}
}