kekitek
kekitek
FFilament
Created by kekitek on 6/22/2024 in #❓┊help
Avoid Section to break and add horizontal scrollbar
I don't want my section to break and instead add a horizontal scrollbar, but I can't get this to work. I tried to add overflow-auto like so
Section::make()
->extraAttributes(['class' => 'overflow-auto'])
->schema([
Section::make()
->extraAttributes(['class' => 'overflow-auto'])
->schema([
22 replies
FFilament
Created by kekitek on 6/15/2024 in #❓┊help
How to import json/array from csv?
No matter what I try I can't import json/array properly from a csv file. This is how it looks in file
[{"cost":0,"name":"Home inspection","in_loan":0,"percent":0,"cost_type":"set-amount"},{"cost":0,"name":"Appraisal","in_loan":0,"percent":0,"cost_type":"set-amount"},{"cost":0,"name":"Loan Points","in_loan":0,"percent":0,"cost_type":"set-amount"},{"cost":0,"name":"Lender Fees","in_loan":0,"percent":0,"cost_type":"set-amount"},{"cost":0,"name":"Title & Escrow Fees","in_loan":0,"percent":0,"cost_type":"set-amount"},{"cost":0,"name":"Transfer Taxes","in_loan":0,"percent":0,"cost_type":"set-amount"},{"cost":0,"name":"Attorney Fees","in_loan":0,"percent":0,"cost_type":"set-amount"},{"cost":0,"name":"Wholesaler Fees","in_loan":0,"percent":0,"cost_type":"set-amount"}]
[{"cost":0,"name":"Home inspection","in_loan":0,"percent":0,"cost_type":"set-amount"},{"cost":0,"name":"Appraisal","in_loan":0,"percent":0,"cost_type":"set-amount"},{"cost":0,"name":"Loan Points","in_loan":0,"percent":0,"cost_type":"set-amount"},{"cost":0,"name":"Lender Fees","in_loan":0,"percent":0,"cost_type":"set-amount"},{"cost":0,"name":"Title & Escrow Fees","in_loan":0,"percent":0,"cost_type":"set-amount"},{"cost":0,"name":"Transfer Taxes","in_loan":0,"percent":0,"cost_type":"set-amount"},{"cost":0,"name":"Attorney Fees","in_loan":0,"percent":0,"cost_type":"set-amount"},{"cost":0,"name":"Wholesaler Fees","in_loan":0,"percent":0,"cost_type":"set-amount"}]
This is in my importer class
ImportColumn::make('purchase_costs')
->castStateUsing(function (string $state): ?array {
if (blank($state)) {
return null;
}

return json_decode($state, true); // Decode JSON string to an associative array
}),
ImportColumn::make('purchase_costs')
->castStateUsing(function (string $state): ?array {
if (blank($state)) {
return null;
}

return json_decode($state, true); // Decode JSON string to an associative array
}),
This is how it looks in my DB
"[{\"cost\":0,\"name\":\"Home inspection\",\"in_loan\":0,\"percent\":0,\"cost_type\":\"set-amount\"},{\"cost\":0,\"name\":\"Appraisal\",\"in_loan\":0,\"percent\":0,\"cost_type\":\"set-amount\"},{\"cost\":0,\"name\":\"Loan Points\",\"in_loan\":0,\"percent\":0,\"cost_type\":\"set-amount\"},{\"cost\":0,\"name\":\"Lender Fees\",\"in_loan\":0,\"percent\":0,\"cost_type\":\"set-amount\"},{\"cost\":0,\"name\":\"Title & Escrow Fees\",\"in_loan\":0,\"percent\":0,\"cost_type\":\"set-amount\"},{\"cost\":0,\"name\":\"Transfer Taxes\",\"in_loan\":0,\"percent\":0,\"cost_type\":\"set-amount\"},{\"cost\":0,\"name\":\"Attorney Fees\",\"in_loan\":0,\"percent\":0,\"cost_type\":\"set-amount\"},{\"cost\":0,\"name\":\"Wholesaler Fees\",\"in_loan\":0,\"percent\":0,\"cost_type\":\"set-amount\"}]"
"[{\"cost\":0,\"name\":\"Home inspection\",\"in_loan\":0,\"percent\":0,\"cost_type\":\"set-amount\"},{\"cost\":0,\"name\":\"Appraisal\",\"in_loan\":0,\"percent\":0,\"cost_type\":\"set-amount\"},{\"cost\":0,\"name\":\"Loan Points\",\"in_loan\":0,\"percent\":0,\"cost_type\":\"set-amount\"},{\"cost\":0,\"name\":\"Lender Fees\",\"in_loan\":0,\"percent\":0,\"cost_type\":\"set-amount\"},{\"cost\":0,\"name\":\"Title & Escrow Fees\",\"in_loan\":0,\"percent\":0,\"cost_type\":\"set-amount\"},{\"cost\":0,\"name\":\"Transfer Taxes\",\"in_loan\":0,\"percent\":0,\"cost_type\":\"set-amount\"},{\"cost\":0,\"name\":\"Attorney Fees\",\"in_loan\":0,\"percent\":0,\"cost_type\":\"set-amount\"},{\"cost\":0,\"name\":\"Wholesaler Fees\",\"in_loan\":0,\"percent\":0,\"cost_type\":\"set-amount\"}]"
4 replies
FFilament
Created by kekitek on 6/14/2024 in #❓┊help
Import action make field nullable does not work
I want to store fields in db even if they are not valid or empty as null, but I can't get this to work. I have tried to cast the field to null but it always says "must be valid date".
return [
ImportColumn::make('salutation')
->rules(['max:255']),
ImportColumn::make('firstname')
->requiredMapping()
->rules(['required', 'max:255']),
ImportColumn::make('lastname')
->requiredMapping()
->rules(['required', 'max:255']),
ImportColumn::make('email')
->rules(['nullable', 'max:255']),
ImportColumn::make('phone')
->rules(['max:255']),
ImportColumn::make('whatsapp_number')
->rules(['max:255']),
ImportColumn::make('follow_up')
->castStateUsing(fn($state) => $state ? Carbon::parse($state) : null) // here for example
->rules(['max:255']),
ImportColumn::make('notes')
->rules(['max:10000']),
];
return [
ImportColumn::make('salutation')
->rules(['max:255']),
ImportColumn::make('firstname')
->requiredMapping()
->rules(['required', 'max:255']),
ImportColumn::make('lastname')
->requiredMapping()
->rules(['required', 'max:255']),
ImportColumn::make('email')
->rules(['nullable', 'max:255']),
ImportColumn::make('phone')
->rules(['max:255']),
ImportColumn::make('whatsapp_number')
->rules(['max:255']),
ImportColumn::make('follow_up')
->castStateUsing(fn($state) => $state ? Carbon::parse($state) : null) // here for example
->rules(['max:255']),
ImportColumn::make('notes')
->rules(['max:10000']),
];
Help is much appreciated! 🙂
38 replies
FFilament
Created by kekitek on 6/10/2024 in #❓┊help
How to store foreign key in import action?
I am trying to store the foreign key in a import action without success, but I don't know why. This should be possible right? This is the code
public function resolveRecord(): ?Client
{
return Client::firstOrNew([
'user_id' => Auth::user()->id,
'email' => $this->data['email'],
], [
'user_id' => Auth::user()->id,
'firstname' => $this->data['firstname'],
'lastname' => $this->data['lastname'],
]);
}
public function resolveRecord(): ?Client
{
return Client::firstOrNew([
'user_id' => Auth::user()->id,
'email' => $this->data['email'],
], [
'user_id' => Auth::user()->id,
'firstname' => $this->data['firstname'],
'lastname' => $this->data['lastname'],
]);
}
2 replies