shopeebot
shopeebot
FFilament
Created by shopeebot on 5/28/2024 in #❓┊help
Has anyone implement QR Code Scanner in a field for filament?
So a simple QR that will fill in a certain field on successful scan
6 replies
FFilament
Created by shopeebot on 5/27/2024 in #❓┊help
Why repeater data does not included in mutateFormDataBeforeCreate() function?
How do I access repeater data from the CreateInvoice Pages? It gave me this error:
Undefined array key "item_variations"
Undefined array key "item_variations"
I tried to dump the $data and the key for the repeater does not exist. My code:
<?php
class CreateInvoice extends CreateRecord
{
protected static string $resource = InvoiceResource::class;
protected function mutateFormDataBeforeCreate(array $data): array
{
\Midtrans\Config::$serverKey = config('midtrans.serverKey');
\Midtrans\Config::$isProduction = false;
\Midtrans\Config::$isSanitized = true;
\Midtrans\Config::$is3ds = true;
$repeater = $data['item_variations'];
$totalPrice = 0;
for ($i=0; $i < count($repeater); $i++) {
$totalPrice += $repeater[$i]['price'];
}
$partner = Partner::find($data['partner_id']);

$params = array(
'transaction_details' => array(
'order_id' => rand(),
'gross_amount' => $totalPrice,
),
'customer_details' => array(
'first_name' => $partner->name,
'phone' => $partner->phone_number,
),
);

$snapToken = \Midtrans\Snap::getSnapToken($params);
$data['midtrans_order_id'] = $snapToken;

return $data;
}
}
<?php
class CreateInvoice extends CreateRecord
{
protected static string $resource = InvoiceResource::class;
protected function mutateFormDataBeforeCreate(array $data): array
{
\Midtrans\Config::$serverKey = config('midtrans.serverKey');
\Midtrans\Config::$isProduction = false;
\Midtrans\Config::$isSanitized = true;
\Midtrans\Config::$is3ds = true;
$repeater = $data['item_variations'];
$totalPrice = 0;
for ($i=0; $i < count($repeater); $i++) {
$totalPrice += $repeater[$i]['price'];
}
$partner = Partner::find($data['partner_id']);

$params = array(
'transaction_details' => array(
'order_id' => rand(),
'gross_amount' => $totalPrice,
),
'customer_details' => array(
'first_name' => $partner->name,
'phone' => $partner->phone_number,
),
);

$snapToken = \Midtrans\Snap::getSnapToken($params);
$data['midtrans_order_id'] = $snapToken;

return $data;
}
}
5 replies
FFilament
Created by shopeebot on 5/23/2024 in #❓┊help
Auto select parent as foreign key on relation manager
How do I auto select parent when creating a record on relation manager? Is it has to be done with "Customizing data before saving" thing?
6 replies