Stricks
Stricks
FFilament
Created by Stricks on 10/18/2024 in #❓┊help
Can I use a filament table outside of Filament directories?
I love Filament so much that I want to use its Table feature in another part of my code. This code has nothing to do with Filament. Because this is not a Filament Resource, I don't know how to invoke a Table and feed it headers, columns, etc, as I would in a traditional Resource. Is this possible to do, or must Tables, with their magical properties, live in a typical Resource PHP file under the Filament directory structure?
46 replies
FFilament
Created by Stricks on 10/16/2024 in #❓┊help
Find a reporting system that allows for CRUD
I've found lots of reporting tools that let you hard-code a report, both in Laravel, Filament, and plain PHP, but what I am looking for is code that gives a friendly UI, allows the user to pick fields from various SQL tables, add filters, save the report, and of course display it. Essentially, I want a CRUD-like interface to let users create their own reports, but have a friendly (no actual field names displayed) UI. I wrote something to do this 12 yrs ago, but I don't want to port it into Laravel/Filament as it has bad UI and only supports AND clauses between JOINed tables. Does anyone know of code that would do this? TIA!
1 replies
FFilament
Created by Stricks on 10/6/2024 in #❓┊help
Clicking on a child record in a table to take you to that record - not edit
I have a form edit for a Parent record that has Child records under it. This works well. By default, when you click on a Child record in the table, it edits that record in a modal. I want to change that so that the page moves to the Child record in edit mode. I think something like this would work ->url("/childResourceName/childResourceNameId/edit") , but to do that I would need a value for the childResourceNameId and I don't know how to get that. Or am I trying to code this, and there's a way to configure the Filament table to do this? I've tried this example, but can't get the syntax correct:
TextEntry::make('title')
->url(fn (Post $record): string => route('posts.edit', ['post' => $record]))
TextEntry::make('title')
->url(fn (Post $record): string => route('posts.edit', ['post' => $record]))
Any advice on which way to attack this?
13 replies
FFilament
Created by Stricks on 10/5/2024 in #❓┊help
Making a Form Toggle read-only
I have a boolean field that I'd like to show as a toggle button, but I'd like to disable the button so it's read-only. There doesn't appear to be an attribute to do this. Or maybe I'm doing this the wrong way. Is there a better way to display a boolean and color code it? My is_current_member boolean is a calculated field, so the user can't control it (thus the need for read-only). I'm currently using this:
Toggle::make('is_current_member')
->onColor('success')
->offColor('warning')
->inline() // Show label on the same line
->label('Current Member?'),
Toggle::make('is_current_member')
->onColor('success')
->offColor('warning')
->inline() // Show label on the same line
->label('Current Member?'),
4 replies
FFilament
Created by Stricks on 10/3/2024 in #❓┊help
multi-tenant: It doesn't filter everwhere
I'm a newbie at Filament, but have the basic many-to-many relations in my tables working and in the UI. Now I've added multi-tenant, and have it working in the UI for my Resources by including this in the top of each Resource Class: protected static ?string $tenantOwnershipRelationshipName = 'team';. This works well when I am into the UI for reach Resource, but when I am on the default Admin page and have added widgets with this code, it seems to ignore the multi-tenant filter. Or maybe I need to add a Global Scope to filter it? This is the code that is not filtering (eg. shows all records) - any clues?:
class StatsOverview extends BaseWidget
{
protected static ?string $pollingInterval = '30s'; // Update stats
protected static ?string $tenantOwnershipRelationshipName = 'team';

protected function getStats(): array
{
$team_id = Filament::getTenant()->id;

return [
Stat::make('Families', Family::all()->count())
->url("/admin/$team_id/families"),
Stat::make('People', Person::all()->count())
->url("/admin/$team_id/people"),
Stat::make('Properties', Property::all()->count())
->url("/admin/$team_id/properties"),
];
}
}
class StatsOverview extends BaseWidget
{
protected static ?string $pollingInterval = '30s'; // Update stats
protected static ?string $tenantOwnershipRelationshipName = 'team';

protected function getStats(): array
{
$team_id = Filament::getTenant()->id;

return [
Stat::make('Families', Family::all()->count())
->url("/admin/$team_id/families"),
Stat::make('People', Person::all()->count())
->url("/admin/$team_id/people"),
Stat::make('Properties', Property::all()->count())
->url("/admin/$team_id/properties"),
];
}
}
7 replies
FFilament
Created by Stricks on 9/27/2024 in #❓┊help
Trouble with Attach (Detach works)
No description
53 replies
FFilament
Created by Stricks on 9/24/2024 in #❓┊help
❓How to I embed a table in a form?
No description
6 replies