Files
pos_heidiver/app/Filament/Resources/OjalPresillaResource/Pages/CreateOjalPresilla.php
T
2026-01-29 20:28:26 -05:00

30 lines
782 B
PHP

<?php
namespace App\Filament\Resources\OjalPresillaResource\Pages;
use App\Filament\Resources\OjalPresillaResource;
use Filament\Resources\Pages\CreateRecord;
class CreateOjalPresilla extends CreateRecord
{
protected static string $resource = OjalPresillaResource::class;
protected function mutateFormDataBeforeCreate(array $data): array
{
$tipo = $data['tipo'] ?? 'ojal';
unset($data['tipo']);
// Guardar en la tabla correspondiente
if ($tipo === 'prensilla') {
$record = \App\Models\Prensilla::create($data);
} else {
$record = \App\Models\Ojal::create($data);
}
// Redirigir al listado
$this->redirect(OjalPresillaResource::getUrl('index'));
return $data;
}
}