Jon
Jon
FFilament
Created by Jon on 11/19/2024 in #❓┊help
How do I make text based boolean columns
If i have a boolean column that I would want to display as text instead of an icon, ->boolean doesnt exist on TEXTCOLUMN This example the column references 'is_book' where a false value would mean it is a magazine instead of a book. So I'd like the column labeled "type" to display either 'book', or 'magazine' depending on true or false.
4 replies
FFilament
Created by Jon on 11/15/2024 in #❓┊help
can someone help guide me in setting up filament for specific users or groups?
I'm fairly sure this is something to do with multi-tenacy. But in my app, I have my backend Admin panel which is fine. But I also want to use filament to handle things like user or group settings. Of course this would need to ensure that a user or group admin only has access to their data. All the documents reference teams, which is not what I am looking for, though may be the same idea.
I am just a bit lost in how to approach this. If i have a user panel, I have a few tables that all relate to user settings, but the user table itself also has multiple columns that would be better if i could split them into several sections. I currently have it set up as tabs, for just the user table data. but can those tabs be made into sidebar links in the panel? If i have a pivot table, that also has its own fields, I'd like this to also be its own form in the user panel. So admin panel manages all things related to SITE if user = admin User panel -- manages all things related to logged in user Group panel-- manages all things related to group if user = group_admin or owner Groups and users will have view access to any logged in user I just need a little help figuring out how to set up this front end panel arrangement.
4 replies
FFilament
Created by Jon on 10/23/2024 in #❓┊help
How do I filter count columns
I have a column to display member counts of a group.
TextColumn::make('active_members_count')
->label('Members')
->counts('activeMembers')
->sortable()
->grow(false)
->wrapHeader()
,
TextColumn::make('active_members_count')
->label('Members')
->counts('activeMembers')
->sortable()
->grow(false)
->wrapHeader()
,
I am attempting to allow a filter that affects this column, but I am not sure the proper way to reference it as it is a calculated value.
Filter::make('active_members_count')
->form([
Fieldset::make('Members')
->schema([
TextInput::make('min')->numeric()
->label('Min Members'),
TextInput::make('max')->numeric()
->label('Max Members'),
]),
])
->query(function (Builder $query, array $data): Builder {
return $query
->when(
$data['min'],
fn(
Builder $query,
$members
): Builder => $query->having('active_members_count',
'>=', $members)
)
->when(
$data['max'],
fn(
Builder $query,
$members
): Builder => $query->having('active_members_count',
'<=', $members)
);
}),
Filter::make('active_members_count')
->form([
Fieldset::make('Members')
->schema([
TextInput::make('min')->numeric()
->label('Min Members'),
TextInput::make('max')->numeric()
->label('Max Members'),
]),
])
->query(function (Builder $query, array $data): Builder {
return $query
->when(
$data['min'],
fn(
Builder $query,
$members
): Builder => $query->having('active_members_count',
'>=', $members)
)
->when(
$data['max'],
fn(
Builder $query,
$members
): Builder => $query->having('active_members_count',
'<=', $members)
);
}),
Thanks
3 replies
FFilament
Created by Jon on 2/10/2024 in #❓┊help
How can I save data (TAGS) into a M:M polymorphic array? I have been struggling w/ this for months
GOAL: Loop through tags (ratings) that correspond to the Hobby model: Sample data: https://imgur.com/a/WDe6Z19 An example: if the taggable table lists tag_id 2 [solo] belongs to hobby id 1 , TAG 2 would be a child to tag 1 [activity type] in which the rendered selects would simply loop through all parent ratings, and then child ratings of each and if a hobby has a child connection, it marks it as selected. Parent Tags in this case will never be a selected option, they only serve to create the input label: The child tags form the input's options Selected values need to be saved to hobbyRatings relationship which is a M:M polymorphic relationship: I have tried to make this work in several ways which i will post below. I can get the select statements to load properly, but they are not saving. Note, this ratings form is a sub form within the hobbyResource. The hobby-specific data saves, but I cannot get the rating data to save. nor do i have a clue how to view the "data" object to see how i might need to format the code differently. Any help would be greatly appreciated. To keep this short here are the questions on LARACASTS: https://laracasts.com/discuss/channels/filament/filament-v3-adding-a-livewire-component -- this attempt using livewire https://laracasts.com/discuss/channels/filament/how-do-i-manually-save-a-generated-field-with-filament --this attempt directly in the resource
2 replies
FFilament
Created by Jon on 12/6/2023 in #❓┊help
How do I create a group of SELECTs with a foreach loop
I am having trouble with my form creation in that I dont know how to go about inserting basic php to generate form data. In this instance, I want to loop through all my Rating tags in the database along with the choices for each. but I dont know how to do this within the schema The available rating options may change so it needs to be generated dynamically
Section::make('Ratings')
->schema([

foreach($model->hobbyRatings()->where('parent_id',null) as $rating){
Select::make($rating->tag)
->options(function (Builder $query) use ($rating) {
return $query->where('parent_id', $rating->id)->get();
});
}


])

->columnSpanFull(),
Section::make('Ratings')
->schema([

foreach($model->hobbyRatings()->where('parent_id',null) as $rating){
Select::make($rating->tag)
->options(function (Builder $query) use ($rating) {
return $query->where('parent_id', $rating->id)->get();
});
}


])

->columnSpanFull(),
2 replies
FFilament
Created by Jon on 12/5/2023 in #❓┊help
If I want to create panels for Users or Groups to edit their settings, is that a multitenant setup
part of my site needs front end management that allows users and or groups to manage settings specific to their profile. I figured a user and group panel might be a good way to do this, but should i be looking at multi tenant setups, or is there a better way to handle this? Also I created a vendor panel as well then set up the access as "
public function canAccessPanel(Panel $panel): bool
{
if ($panel->getId() === 'admin') {
return auth()->check()
&& auth()->user()->hasRole([
'admin', 'super-admin',
]);
}
if ($panel->getId() === 'vendor') {
return true;
}

return true;
}
public function canAccessPanel(Panel $panel): bool
{
if ($panel->getId() === 'admin') {
return auth()->check()
&& auth()->user()->hasRole([
'admin', 'super-admin',
]);
}
if ($panel->getId() === 'vendor') {
return true;
}

return true;
}
but every panel but vendor allows me to access it. Vendor panel is blocking access. No idea why. if the path is simply /vendor is their a route conflict maybe?
4 replies