Harvey
Harvey
FFilament
Created by Harvey on 4/29/2024 in #❓┊help
Reuse macro callbacks for multiple classes
Is there a way of extracting the anonoymous functions to a class function? I would like it so I can just pass $this->onlyForAdmins, or [$this, 'onlyForAdmins'] and not have to duplicate the func body every time.
Field::macro('onlyForAdmins', function () {
return $this->visible(function () {
return Auth::user()->is_admin;
});
});

MountableAction::macro('onlyForAdmins', function () {
return $this->visible(function () {
return Auth::user()->is_admin;
});
});

ActionGroup::macro('onlyForAdmins', function () {
return $this->visible(function () {
return Auth::user()->is_admin;
});
});
Field::macro('onlyForAdmins', function () {
return $this->visible(function () {
return Auth::user()->is_admin;
});
});

MountableAction::macro('onlyForAdmins', function () {
return $this->visible(function () {
return Auth::user()->is_admin;
});
});

ActionGroup::macro('onlyForAdmins', function () {
return $this->visible(function () {
return Auth::user()->is_admin;
});
});
I tried to just extract it like I mentioned, but it complains that $this->visible() is not a method on the class. Is this a Laravel macro thing?
4 replies
FFilament
Created by Harvey on 4/19/2024 in #❓┊help
Custom table columns per table tab
I'm moving from Nova, and basically want to replicate what a Lense does in Filament. So when I switch to my "Pending Payments" tab, I want to also add a column showing "payment total". Is this at all possible? Or do I need to have separate pages/tables linked to these tabs?
6 replies
FFilament
Created by Harvey on 1/31/2024 in #❓┊help
TextEntry placeholder not working for related models
TextEntry::make('book.description')
->placeholder('None'),
TextEntry::make('book.description')
->placeholder('None'),
This should show "None" but is blank. I can see in
vendor/filament/infolists/resources/views/components/text-entry.blade.php::65
vendor/filament/infolists/resources/views/components/text-entry.blade.php::65
the state get's wrapped, which is causing it to be [ 0 => "" ] which resolves to true when deciding whether or not to show the placeholder. is this a bug?
6 replies
FFilament
Created by Harvey on 1/26/2024 in #❓┊help
Are table actions slow?
I am migrating a website from Nova to Filament and I was just comparing the page load times. I understand Nova is Vue and uses ajax(inertia), but a pure livewire table is very quick. I have a table with 25 rows and 1 column, and when I add view, edit and delete iconButtons it slows by 350ms... I have run php artisan icons:cache with no difference. Not sure why it's slowing down so much, is blade rendering just slow with this many views?
17 replies
FFilament
Created by Harvey on 1/25/2024 in #❓┊help
canAccess() method not working when added to Custom Page
No description
5 replies
FFilament
Created by Harvey on 1/15/2024 in #❓┊help
How to add field error manually in Livewire component
I have a custom Livewire component with a form(), and I need to give a field an error message after submission. The field is called "code", and I need to add an error message of "Invalid code" only after they have submitted the form. I assumed I would just do $this->addError('code', 'Invalid code') but I cannot see it, am I missing a prefix or something? Or have I missed something in the docs?
5 replies