fadil
teach we about query logic in filament
TextInput::make('booking_code')
->afterStateHydrated(function () {
$prefix = 'ORD-PS-';
$latestBooking = Booking::orderBy('id', 'desc')->first();
if ($latestBooking) {
$bookingNumber = intval(substr($latestBooking->booking_code, strlen($prefix)));
$bookingNumber++;
} else {
$bookingNumber = 1;
}
$bookingCode = $prefix . str_pad($bookingNumber, 4, '0', STR_PAD_LEFT);
})
like this? im sorry im very very very beginner
11 replies
teach we about query logic in filament
TextInput::make('booking_code')
->mutateFormDataUsing(function (array $bookingCode): array {
$prefix = 'ORD-PS-';
$latestBooking = Booking::orderBy('id', 'desc')->first();
if ($latestBooking) {
$bookingNumber = intval(substr($latestBooking->booking_code, strlen($prefix)));
$bookingNumber++;
} else {
$bookingNumber = 1;
}
// Buat kode booking dengan format "ordps0001"
$bookingCode = $prefix . str_pad($bookingNumber, 4, '0', STR_PAD_LEFT);
return $bookingCode;
})
i try it and i got an error
Method Filament\Forms\Components\TextInput::mutateFormDataUsing does not exist.
how to fix this error sir?
11 replies
array to string convertion
sorry for my mistake, i have an eror in this case, i wan to create a playstation form and i have many to many relationship with jenisgame, i have a pivot table on my database its called playstation_jenisgame.
if i want to create my playstation in playstation form a eror massage (Array to String Convertion)
i have a casts in my playstation models protected
$casts = ['jenisgame_id' => 'array'];
and the eror massage still appears7 replies