36 lines
1.1 KiB
PHP
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;
|
|
}
|
|
}
|