Stricks
Stricks
FFilament
Created by Stricks on 3/18/2025 in #❓┊help
Passing data to a custom page that includes the Filament menu system
Situation While the majority of my single Admin panel works well in Filament, I need a report writer that allows users to select fields and build their own reports. Since I can't find this in Laravel/Filament, I want to use a non-Laravel Class I wrote and port it. So I need to create a page that has my Filament menu but allows me to write typical Controller code that passes values into a generic View that's built to display a report. Trying this method I'm trying to use the Pages doc (https://filamentphp.com/docs/3.x/panels/pages) in Laravel 12 w/ Filament v3 using php artisan make:filament-page I have created a working page that also has the menu on it. Problem Being better at Laravel than Filament, I'm looking for the 'controller' function that would call the 'view'. I do see the Page code that begins with class RunReport extends Page,, but it's got no functions in it, and it magically displays the View just fine. Should I put a function in this class? If so, what should it's name be? I feel like I may be missing the point here, as the docs don't seem to address this. Question While I'm super impressed with Filament, I now need to put it into 'manual' mode so I can run some code before the View is called, and I can't figure out where this is put. Can someone point me in the right direction? Or if I'm not using the right solution to the problem, please point be in the right direction. I'm happy to share code if that helps. TIA, Dave
13 replies
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?
49 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