usmcgator
usmcgator
FFilament
Created by usmcgator on 7/17/2023 in #❓┊help
display count matching getTableRecordClassesUsing
Here's the solution. In this scenario, it looks for the value from the assessment column for that record and if its value is null, highlight the row with as priority (dark:border.etc if dark mode). If it's not null style it based on the value in the mission column. I then have different styles for each mission value that could exist.
protected function getTableRecordClassesUsing(): ?Closure
{
return fn (Model $record) => match ($record->assessment) {
null => [
'priority',
'dark:border-orange-300' => config('tables.dark_mode'),
],
default => $record->mission,
};
}
protected function getTableRecordClassesUsing(): ?Closure
{
return fn (Model $record) => match ($record->assessment) {
null => [
'priority',
'dark:border-orange-300' => config('tables.dark_mode'),
],
default => $record->mission,
};
}
4 replies
FFilament
Created by usmcgator on 5/23/2023 in #❓┊help
counts not working on relationship
it was a relationship issue, we worked things out 🙂 Thanks
8 replies
FFilament
Created by usmcgator on 5/23/2023 in #❓┊help
counts not working on relationship
I tried that, and it correctly displayed the count for one mission, but reported no records for the second, even though there are.
$this->hasManyThrough(Goal::class, Mission::class, 'id', 'mission_id');
$this->hasManyThrough(Goal::class, Mission::class, 'id', 'mission_id');
8 replies
FFilament
Created by usmcgator on 5/22/2023 in #❓┊help
Custom table action for related resources
if I change it from CreateAction to just Action, nothing happens when I click on the action.
4 replies
FFilament
Created by usmcgator on 5/11/2023 in #❓┊help
consume an external API with Filament Tables
this solved my problem, thanks! sudo apt-get install php-sqlite3
12 replies
FFilament
Created by usmcgator on 5/11/2023 in #❓┊help
consume an external API with Filament Tables
I didn't, but just installed it and restarted Apache, same error: sudo apt install php8.0-sqlite3 sudo service apache2 restart
12 replies
FFilament
Created by usmcgator on 5/6/2023 in #❓┊help
Wizard Steps as Table views?
I have this working by iterating through livewire components, but I'm not using the Wizard feature. It'd be nice to as it does all the styling/navigation.
5 replies
FFilament
Created by usmcgator on 4/26/2023 in #❓┊help
Policy for Settings Plugin?
That solved the problem, thanks.
6 replies
FFilament
Created by usmcgator on 4/26/2023 in #❓┊help
Policy for Settings Plugin?
I just implemented this code, which works to protect the page, but it appears to have caused a kink in the settings plugin. I can get to the settings page with the proper role, but it's no longer pulling up existing values from the database into the form. It writes the values to the database correctly, but going to the form after a successful save shows empty values in the form fields, yet the updated values are in the database. After uncommenting out the following code, it goes back to working correctly, except other users can get to it without this code:
protected static function shouldRegisterNavigation(): bool
{
return auth()->user()->hasAnyRole('admin');
}

public function mount(): void
{
abort_unless(auth()->user()->hasAnyRole('admin'), 403);
}
protected static function shouldRegisterNavigation(): bool
{
return auth()->user()->hasAnyRole('admin');
}

public function mount(): void
{
abort_unless(auth()->user()->hasAnyRole('admin'), 403);
}
6 replies
FFilament
Created by usmcgator on 4/24/2023 in #❓┊help
Write to cache after submit
whoa! that looks like exactly what I need. I'll check it out. Thanks for your help.
16 replies
FFilament
Created by usmcgator on 4/24/2023 in #❓┊help
Write to cache after submit
the resource model is actually Settings 🙂 This looks like it'll work. So will I be able to get the value using Cache::get('start_date')?
16 replies
FFilament
Created by usmcgator on 4/24/2023 in #❓┊help
Write to cache after submit
I just don't want to make a DB call for a value used often, so I wanted to cache it in the file cache and then use Cache::get('start_date') to get the value when needed for a query. If that value is not in cache, then get it from the DB. Something like that
16 replies
FFilament
Created by usmcgator on 4/24/2023 in #❓┊help
Write to cache after submit
I could set this value in the .env file which will get cached, but I want to give admins the ability to set the value using a form, which in turn writes to the file cache so I can just reference the cache value instead of doing a DB call every time.
16 replies
FFilament
Created by usmcgator on 4/24/2023 in #❓┊help
Write to cache after submit
I'd like to write the value to cache to reduce load, if not in cache, it will read from the DB. This is what I'd like to do after it submits the form: Cache::forever('start_date', $record->start_date);
16 replies
FFilament
Created by usmcgator on 4/18/2023 in #❓┊help
TableWidget Actions not working as expected
Wasn't sure how to flush out your suggestion, is this closer?
protected function getTableHeaderActions(): array
{
return [
CreateAction::make()->form([
Select::make('type')
->required()
->options([
'book' => 'Book',
'chapter' => 'Chapter',
'journal' => 'Journal',
])
]),
];
}
protected function getTableHeaderActions(): array
{
return [
CreateAction::make()->form([
Select::make('type')
->required()
->options([
'book' => 'Book',
'chapter' => 'Chapter',
'journal' => 'Journal',
])
]),
];
}
19 replies
FFilament
Created by usmcgator on 4/18/2023 in #❓┊help
TableWidget Actions not working as expected
got it all working with this:
protected function getTableHeaderActions(): array
{
return [
CreateAction::make()->form(function (Publication $publication) {
$form = Form::make('newPublication', [
'model' => $publication,
]);
$form->schema([
Select::make('type')
->required()
->options([
'book' => 'Book',
'chapter' => 'Chapter',
'journal' => 'Journal',
]),
// ...
]);
return $form->getSchema();
}),
];
}
protected function getTableHeaderActions(): array
{
return [
CreateAction::make()->form(function (Publication $publication) {
$form = Form::make('newPublication', [
'model' => $publication,
]);
$form->schema([
Select::make('type')
->required()
->options([
'book' => 'Book',
'chapter' => 'Chapter',
'journal' => 'Journal',
]),
// ...
]);
return $form->getSchema();
}),
];
}
19 replies
FFilament
Created by usmcgator on 4/18/2023 in #❓┊help
TableWidget Actions not working as expected
user error, I got the button to show up now using the above method, I just need to redirect it to the correct create form.
19 replies
FFilament
Created by usmcgator on 4/18/2023 in #❓┊help
TableWidget Actions not working as expected
I was trying to get the "Add Resource" button to show up in the table header of the TableWidget, like it does the table when viewing that table using the auto generated resource view page. I tried this, but it didn't make the button show up on the TableWidget:
protected function getTableHeaderActions(): array
{
return [
Actions\CreateAction::make(),
];
}
protected function getTableHeaderActions(): array
{
return [
Actions\CreateAction::make(),
];
}
19 replies
FFilament
Created by usmcgator on 4/18/2023 in #❓┊help
TableWidget Actions not working as expected
still having an issue adding an "Add Resource" button to the widget, but the actions all work.
19 replies