Davide Cariola
Davide Cariola
FFilament
Created by Davide Cariola on 7/6/2024 in #❓┊help
Problem with CreateOptionForm
No description
2 replies
FFilament
Created by Davide Cariola on 7/2/2024 in #❓┊help
Filter for calculated field
Thanks everyone. Tomorrow I'll work on it and let you know!
7 replies
FFilament
Created by Davide Cariola on 7/2/2024 in #❓┊help
Filter for calculated field
Hi, thank you for the response! I was wandering about an SQL view. When you talk about a virtual column you intend in filament or in the DB?
7 replies
FFilament
Created by Davide Cariola on 6/23/2024 in #❓┊help
Table Filter for Repeater Json Column
The error was caused by my test data: by using json_encode in the factory code, together with casting, the json was saved with the "". Maybe it can be useful in the future for someone with a problem similar to mine 🥲
6 replies
FFilament
Created by Davide Cariola on 6/23/2024 in #❓┊help
Table Filter for Repeater Json Column
No description
6 replies
FFilament
Created by Davide Cariola on 6/23/2024 in #❓┊help
Table Filter for Repeater Json Column
I've understood that the problem is that the JSON is saved as a string. In fact, I've delete the "" manually in the db and the query works. But how to do it in the code? 😅
6 replies
FFilament
Created by Aminne on 6/23/2024 in #❓┊help
custom select componenet with phone code , and country emoji
If I understood correctly what you need, you can use this: https://filamentphp.com/plugins/ysfkaya-phone-input
4 replies
FFilament
Created by Davide Cariola on 6/16/2024 in #❓┊help
Filter's query returns collection but table stays empty
I solved it by simplifying the callback within query, like this:
->query(function (Builder $query, array $data): Builder {
if($data['pricing']['max'] > 0){
$query = $query->where('price', '<=', $data['pricing']['max']);
} else {
$query = $query->where('price', '<=', $this->maxPricePossible);
}

if($data['pricing']['min'] > 0){
dump($data['pricing']['min']);
$query = $query->where('price', '>=', $data['pricing']['min']);
} else {
$query = $query->where('price', '>=', 0);
}

return $query;
->query(function (Builder $query, array $data): Builder {
if($data['pricing']['max'] > 0){
$query = $query->where('price', '<=', $data['pricing']['max']);
} else {
$query = $query->where('price', '<=', $this->maxPricePossible);
}

if($data['pricing']['min'] > 0){
dump($data['pricing']['min']);
$query = $query->where('price', '>=', $data['pricing']['min']);
} else {
$query = $query->where('price', '>=', 0);
}

return $query;
4 replies
FFilament
Created by Davide Cariola on 6/16/2024 in #❓┊help
Filter's query returns collection but table stays empty
Here is my code:
'pricing' => Filter::make('pricing')
->form([
MinMaxField::make('pricing')
->label('Pricing (€)')
->default(['min' => null, 'max' => null])
->live()
])
->query(function (Builder $query, array $data): Builder {
return $query
->when(
isset($data['pricing']['min']),
fn (Builder $query) => $query->where('price', '>=', $data['pricing']['min']),
)
->when(
$data['pricing']['max'] !== null && $data['pricing']['max'] == null,
function (Builder $query) {
return $query->where('price', '<=', $this->maxPricePossible);
}
)
->when(
isset($data['pricing']['max']),
fn (Builder $query) => $query->where('price', '<=', $data['pricing']['max'] ?? $this->maxPricePossible),
);
}),
'pricing' => Filter::make('pricing')
->form([
MinMaxField::make('pricing')
->label('Pricing (€)')
->default(['min' => null, 'max' => null])
->live()
])
->query(function (Builder $query, array $data): Builder {
return $query
->when(
isset($data['pricing']['min']),
fn (Builder $query) => $query->where('price', '>=', $data['pricing']['min']),
)
->when(
$data['pricing']['max'] !== null && $data['pricing']['max'] == null,
function (Builder $query) {
return $query->where('price', '<=', $this->maxPricePossible);
}
)
->when(
isset($data['pricing']['max']),
fn (Builder $query) => $query->where('price', '<=', $data['pricing']['max'] ?? $this->maxPricePossible),
);
}),
Am I doing something wrong? Do you have any other ways to solve this? All I would need is for the table to display all the records once the input has been emptied of the maximum price.
4 replies
FFilament
Created by Davide Cariola on 6/14/2024 in #❓┊help
Customize Filter style
Thank you both! I'll try asap
5 replies
FFilament
Created by Patrick on 4/15/2024 in #❓┊help
Disable bulk action button based on checked records
Hi Patrick! Did you find a solution?
3 replies
FFilament
Created by GavTheDev on 5/4/2024 in #❓┊help
Wizard: different steps based on value in step 1
Hi @GavTheDev , yes, In the end, I decided to use visible/hidden
7 replies
FFilament
Created by FilamentDEV on 6/2/2024 in #❓┊help
How to check if filename uploaded, already exists?
If you're preserving the original filenames, you could use ->rules() and then write a Closure which checks the name of the files in the storage. In the closure you could use Storage::disk('your_disk')->exists('file.ext'); Before doing that, read this: https://filamentphp.com/docs/3.x/forms/fields/file-upload#security-implications-of-controlling-file-names there are several security implications for why you don't want to preserve original filenames. Good coding! 😄
3 replies
FFilament
Created by Davide Cariola on 6/1/2024 in #❓┊help
Go to different step based on field value
I managed somehow but the UX is not the best. I persisted the step in the query string and I used this:
->afterValidation(function(Get $get){
if($get('product_id') == 1){
redirect('admin/publications/create?step=linking');
}
}),
->afterValidation(function(Get $get){
if($get('product_id') == 1){
redirect('admin/publications/create?step=linking');
}
}),
but you'll see the redirecting, which is unfortunate. Maybe someone has some ideas to start from here and make it smoother?
3 replies
FFilament
Created by Davide Cariola on 5/29/2024 in #❓┊help
Hide create button in a form with wizard
Hi @Vp, got it in the morning. The problem was that I was using the method in the wrong place 😄 Thank you so much for the tip. For others:
//App\Filament\Resources\MyResource\Pages\CreateResource.php
protected function getFormActions(): array
{
return [
$this->getCancelFormAction(),
];
}
//App\Filament\Resources\MyResource\Pages\CreateResource.php
protected function getFormActions(): array
{
return [
$this->getCancelFormAction(),
];
}
this hides every button except the one you choose to show (you can find the methods in the CreateRecord class
6 replies
FFilament
Created by Davide Cariola on 5/29/2024 in #❓┊help
Hide create button in a form with wizard
Thank you so much, I'll look into it!
6 replies
FFilament
Created by GavTheDev on 5/4/2024 in #❓┊help
Wizard: different steps based on value in step 1
Have you solved it?
7 replies
FFilament
Created by Davide Cariola on 10/21/2023 in #❓┊help
Repeater MorphToMany
Then in my PermissionResource I have:
Section::make()
->schema([
Repeater::make('grantables')
->relationship()
->simple(
Select::make('grantable_id')
->relationship(
'role',
'name',
fn(Builder $query) => $query->orderBy('order'),
),
)
->deleteAction(
fn (Action $action) => $action->requiresConfirmation(),
)
->addActionLabel('Assegna a un altro ruolo')
->reorderable(false)
->label('Scegli un ruolo')
->grid(2)
])
->heading('A quali ruoli lo vuoi assegnare?')
->hiddenOn('edit'),
Section::make()
->schema([
Repeater::make('grantables')
->relationship()
->simple(
Select::make('grantable_id')
->relationship(
'role',
'name',
fn(Builder $query) => $query->orderBy('order'),
),
)
->deleteAction(
fn (Action $action) => $action->requiresConfirmation(),
)
->addActionLabel('Assegna a un altro ruolo')
->reorderable(false)
->label('Scegli un ruolo')
->grid(2)
])
->heading('A quali ruoli lo vuoi assegnare?')
->hiddenOn('edit'),
But when I try to save I get this error: SQLSTATE[HY000]: General error: 1364 Field 'grantable_type' doesn't have a default value which I think it means that it cannot manage the grantable_type column with the path to the model. Any idea how to solve? Thanks everyone
2 replies
FFilament
Created by Davide Cariola on 10/20/2023 in #❓┊help
Notification instead of 403 error page
Got it! Thank you so much for your time!
9 replies
FFilament
Created by Davide Cariola on 10/20/2023 in #❓┊help
Notification instead of 403 error page
Hi! Yeah, that is the next step. But I'd like to avoid people from forcing its way through the uri. But feel free to tell me if it does make sense or not 😄
9 replies