Garadit
Garadit
FFilament
Created by Garadit on 10/31/2024 in #❓┊help
Lazy load table column
Yes, Thanks for the insight @Mohamed Ayaou . I think the lazy load approach is still needed, especially when calling multiple APIs and running huge computed data. I'm still thinking about how to implement it, like we apply toggleable() but it triggers automatically when the table is rendered.
18 replies
FFilament
Created by Garadit on 10/31/2024 in #❓┊help
Lazy load table column
Thanks @CodeWithDennis . Bad queries are the main problem, right in getStatusAttribute. It calls more than 1000 queries, like, that's huge. Now that I'm using raw queries, the performance has improved significantly.
18 replies
FFilament
Created by Garadit on 10/31/2024 in #❓┊help
Lazy load table column
It might be faster if the every process could be done in parallel, unfortunately this is PHP which is blocking by default.
18 replies
FFilament
Created by Garadit on 10/31/2024 in #❓┊help
Lazy load table column
// This is the column
Tables\Columns\TextColumn::make('status')
->badge()
->color(fn (string $state): string => match ($state) {
'Pending' => 'gray',
'SPK Created' => 'primary',
'Partially Printed' => 'info',
'Fully Printed' => 'success',
'Delivery Order Created' => 'info',
'Invoice Created' => 'success',
})
->icon(fn (string $state): string => match ($state) {
'Pending' => 'heroicon-o-clock',
'SPK Created' => 'heroicon-o-cog',
'Partially Printed' => 'heroicon-o-printer',
'Fully Printed' => 'heroicon-o-printer',
'Delivery Order Created' => 'heroicon-o-truck',
'Invoice Created' => 'heroicon-o-printer',
}),

// This is the model attributes
public function getStatusAttribute()
{
$orderProducts = $this->orderProducts;
$statuses = $orderProducts->pluck('status');

switch (true) {
case $this->invoices()->exists():
return 'Invoice Created';

case $this->deliveryOrders()->exists():
return 'Delivery Order Created';

case $statuses->every(fn ($status) => $status === 'Printed'):
return 'Fully Printed';

case $statuses->contains('Printed'):
return 'Partially Printed';

case $this->spks()->exists():
return 'SPK Created';

default:
return 'Pending';
}
}
// This is the column
Tables\Columns\TextColumn::make('status')
->badge()
->color(fn (string $state): string => match ($state) {
'Pending' => 'gray',
'SPK Created' => 'primary',
'Partially Printed' => 'info',
'Fully Printed' => 'success',
'Delivery Order Created' => 'info',
'Invoice Created' => 'success',
})
->icon(fn (string $state): string => match ($state) {
'Pending' => 'heroicon-o-clock',
'SPK Created' => 'heroicon-o-cog',
'Partially Printed' => 'heroicon-o-printer',
'Fully Printed' => 'heroicon-o-printer',
'Delivery Order Created' => 'heroicon-o-truck',
'Invoice Created' => 'heroicon-o-printer',
}),

// This is the model attributes
public function getStatusAttribute()
{
$orderProducts = $this->orderProducts;
$statuses = $orderProducts->pluck('status');

switch (true) {
case $this->invoices()->exists():
return 'Invoice Created';

case $this->deliveryOrders()->exists():
return 'Delivery Order Created';

case $statuses->every(fn ($status) => $status === 'Printed'):
return 'Fully Printed';

case $statuses->contains('Printed'):
return 'Partially Printed';

case $this->spks()->exists():
return 'SPK Created';

default:
return 'Pending';
}
}
What @Mohamed Ayaou said is right, it is necessary to optimize the computing process itself. But I need to adjust to the old code that is already running, so I can't do too much. The 'status' attribute itself takes a long time because it has to check every condition, especially in the every function.
18 replies
FFilament
Created by Garadit on 8/5/2024 in #❓┊help
How is demo.filamentphp.com deployed?
I've tried both ways, from optimize:cache and creating a filament view cache, and the result is about 1 second. I'm okay with that, compared to 3 seconds before. It could be less than a second if the ping to my VPS is less than 200ms.
9 replies
FFilament
Created by Garadit on 8/5/2024 in #❓┊help
How is demo.filamentphp.com deployed?
Thanks for the answer. I have experimented with using containers in Docker as well as with PHP installed on the system via aaPanel. In both I have the OPCache extension enabled. Docker + Nginx = 1.5s aaPanel + Nginx = 3s Still not as fast as demo.filament.com, but shows significant results.
9 replies
FFilament
Created by ocram82 on 4/12/2024 in #❓┊help
Assign role after registration
My bad, I forgot to add a model. I'll probably open a new thread related to this.
94 replies
FFilament
Created by ocram82 on 4/12/2024 in #❓┊help
Assign role after registration
I want to use a fieldset to handle the hasOne relation 'userDetail'. Referring to the latest release, I thought this would be supported by default since $this->form->model($user)->saveRelationships(); is there by default now. But it doesn't work in my case. I don't know if I did it right or not. Someone has asked this kind of question before, but with another version and it is not compatible with the latest version. https://discord.com/channels/883083792112300104/1222497096817447022 Here's the full code I wrote for the custom Regiter.php, wondering what went wrong: https://gist.github.com/TegarAditya/d236edbbf94fd3a8b7fffb5aeedff43d So I will probably use handleRegistration for this. But is that a good idea or a bad practice?
94 replies
FFilament
Created by ocram82 on 4/12/2024 in #❓┊help
Assign role after registration
No description
94 replies
FFilament
Created by ocram82 on 4/12/2024 in #❓┊help
Assign role after registration
Sorry in advance, is this method possible for hasOne relationships? I used fieldset, but after trying it, the relationship data is not saved. Can we save the main data with handleRegistration and then the relationship data afterwards?
94 replies
FFilament
Created by Garadit on 4/4/2024 in #❓┊help
Is it possible to implement HasOne relationship in Registration page?
Thank you very much, the error is gone now ✨
5 replies
FFilament
Created by Garadit on 4/4/2024 in #❓┊help
Is it possible to implement HasOne relationship in Registration page?
Sorry, I can't use fieldset on my CustomRegisterPage. It throws an error "Call to a member function userDetail() on null", I guess because it cannot load the user model. This is the flare debug query form: SELECT * FROM sessions WHERE id = 0dOyTEsseUdHmuiqcxDYjJOekQMFSE3dzKquHkj9 limit 1 Or maybe I missed something.
5 replies
FFilament
Created by Garadit on 3/15/2024 in #❓┊help
Importer causing server restart
This is the Importer code
3 replies
FFilament
Created by Garadit on 2/21/2024 in #❓┊help
Access value outside Repeater
3 replies
FFilament
Created by Garadit on 2/21/2024 in #❓┊help
Access value outside Repeater
Here is the code
3 replies
FFilament
Created by Darpan on 4/10/2023 in #❓┊help
How to prevent already selected value in repeater?
This is working very well, thank you
13 replies
FFilament
Created by Darpan on 4/10/2023 in #❓┊help
How to prevent already selected value in repeater?
Make sense now
13 replies
FFilament
Created by Darpan on 4/10/2023 in #❓┊help
How to prevent already selected value in repeater?
I just want it to work like multiselect, which doesn't show the selection when it's already selected in another repeater. If using rules, won't it check it after the form is submitted (clicked submit)?
13 replies
FFilament
Created by Darpan on 4/10/2023 in #❓┊help
How to prevent already selected value in repeater?
Has the problem been resolved? I'm a bit lost on how to do that for Select Columns
13 replies
FFilament
Created by Garadit on 7/14/2023 in #❓┊help
Using column value or $state in other column
Works very well by adding first(). Thank You.
Tables\Columns\TextColumn::make('difference')
->label('Difference')
->getStateUsing(function ($record) {
return $record->respondent_count - $record->population->first()->sample_size;;
})
->sortable(),
Tables\Columns\TextColumn::make('difference')
->label('Difference')
->getStateUsing(function ($record) {
return $record->respondent_count - $record->population->first()->sample_size;;
})
->sortable(),
6 replies