Oddman
Oddman
FFilament
Created by Oddman on 2/21/2024 in #❓┊help
When logged out and accessing a panel, it's sending me to the site's main login
I'm kinda curious what's going on here - I should be sent to the panel's login page, but I'm instead being sent to the main site login. Any ideas where I should start looking to resolve this?
4 replies
FFilament
Created by Oddman on 1/1/2024 in #❓┊help
How can you create a resource that is based off another model?
I currently have a resource called "User", which has a bunch of filters enabled. One of those filters, is called Role - and when the role of "Author" is checked, it only shows users with that role. Additionally, it enables/disables some functionality for users when viewing authors, such as showing how much they're owed for their content, articles they've published.etc. This is getting out of hand, as I'm having to do a lot of checks all over the place, and I think it would be better if I simply contextualised a new resource, based on the User model. However, I'm having some difficulties setting this up properly. Any suggestions or tips on how to do this "properly" ?
6 replies
FFilament
Created by Oddman on 12/27/2023 in #❓┊help
How do you handle models with custom route keys?
I have articles, their route key is a slug column - I can't see anywhere in the filament docs how to handle this. I'm fine if filament wants to fetch models based on their id, rather than the slug - but it trips over itself:
SELECT
*
FROM
"articles"
WHERE
"id" = getting - acquainted - WITH - brevant
limit
1
SELECT
*
FROM
"articles"
WHERE
"id" = getting - acquainted - WITH - brevant
limit
1
How is this meant to be handled?
5 replies
FFilament
Created by Oddman on 11/27/2023 in #❓┊help
Have some action buttons on left, rest on right?
I want to split my action buttons - I have buttons that allow me to re-order the items (no, the default reorderable stuff doesn't work). So basically I have the ordering arrows on the left, and the edit/delete actions on the right. Also, how do I get a row action to refresh the table?
3 replies
FFilament
Created by Oddman on 11/26/2023 in #❓┊help
Get previous/next record in table?
I'm trying to write some logic in the table builder - I need to get the previous and next row in the table, if at all possible, as this will help determine the actions I need to show/hide in the table records.
3 replies
FFilament
Created by Oddman on 11/14/2023 in #❓┊help
Anyone know of a nested set plugin for filament that works?
Only one I could find was this: https://github.com/antwerpes/filament-nested-set-order But it doesn't appear to work for Filament 3.
2 replies
FFilament
Created by Oddman on 11/12/2023 in #❓┊help
How to colour stats conditionally?
Form elements seem to support a wide variety of options and configuration, but this appears to be mostly missing from stat and widgets. I'd like to format the colour of my stat based on its value, so it could be one of three colours. Currently, the colour option doesn't appear to allow that.
2 replies
FFilament
Created by Oddman on 11/12/2023 in #❓┊help
Is the Split component for tables busted?
I cannot seem to get this to work following the documentation. In fact, it completely breaks my table presentation (no errors). Furthermore, the from() method doesn't appear to be having any effect...
18 replies
FFilament
Created by Oddman on 11/12/2023 in #❓┊help
How to link to a resource from a repeater entry?
I'm listing articles an author has published under the repeater entry, and can't work out how to link to the article they authored.
11 replies
FFilament
Created by Oddman on 11/9/2023 in #❓┊help
Repeater relationship failing as it returns null
I have this weird error - I have a relationship called "contributors" and a repeater block for my articles. The error is as below:
Filament\Support\Services\RelationshipJoiner::prepareQueryForNoConstraints(): Argument #1 ($relationship) must be of type Illuminate\Database\Eloquent\Relations\Relation, null given, called in .../vendor/filament/forms/src/Components/Select.php on line 774
Filament\Support\Services\RelationshipJoiner::prepareQueryForNoConstraints(): Argument #1 ($relationship) must be of type Illuminate\Database\Eloquent\Relations\Relation, null given, called in .../vendor/filament/forms/src/Components/Select.php on line 774
The error stems from this:
Repeater::make('contributors')
->hiddenLabel()
->required(fn (Get $get) => !!$get('published'))
->relationship()
->columns(10)
->reorderable()
->defaultItems(0)
->schema([...])
Repeater::make('contributors')
->hiddenLabel()
->required(fn (Get $get) => !!$get('published'))
->relationship()
->columns(10)
->reorderable()
->defaultItems(0)
->schema([...])
Note that if I remove the relationship() method, it works fine. And here's the relationship defined on my Article model:
public function contributors(): HasMany
{
return $this->hasMany(Contributor::class);
}
public function contributors(): HasMany
{
return $this->hasMany(Contributor::class);
}
I'm not sure what's going on here, as there's nothing wrong with that.
6 replies
FFilament
Created by Oddman on 11/8/2023 in #❓┊help
Select filter for has many or has many through
I've tried everything - every single combination I can think of - query() method won't apply to the query, ever, baseQuery when using a custom attribute complains about the relationship being a hasMany, despite the fact that I'm providing the field to be usable (contributors.user_id) and using the relationship() method on the SelectFilter won't work with HasManyThrough. I've been at this for days now, and am completely stumped. It seems like there's either a bug here, or too much of an opinionated view on how select filters can/should be used.
2 replies
FFilament
Created by Oddman on 11/8/2023 in #❓┊help
Little bit confused by table filters
I'm trying to setup a select dropdown filter, that when selected then needs to join onto another table and find relevant records. If I use the baseQuery method, I can get the query to work, but it's applying, even when the filter isn't set to default. I have not been able to figure out another way to do it. My select filter needs to query a column on a related record, not the main records in the table.
109 replies
FFilament
Created by Oddman on 11/7/2023 in #❓┊help
Datepicker timezones - I don't get this
I'm wanting to have published dates and times in the user's local timezone. This is managed by their browser/OS, and most datepickers will use this to convert to/from the provided date and time (UTC). How can I do this using Filament's datepicker? The documentation seems to imply that you have to provide the user's timezone from the server, which needs to be saved for the user, and is also erroneous (what happens if a user is publishing from a different timezone than normal?)
11 replies
FFilament
Created by Oddman on 11/7/2023 in #❓┊help
How do I align a form input vertically centered within a grid?
As per title, I have a form element that should be aligned center, but because it's not, looks quite odd.
10 replies
FFilament
Created by Oddman on 10/29/2023 in #❓┊help
How to setup a model for tags?
Tags default to be stored as an array on the parent model object, but I want to be able to have tags and taggables in my database, and this is better both for performance, and for things like tag suggestions (which should also be dynamic, based on user input).
2 replies
FFilament
Created by Oddman on 10/16/2023 in #❓┊help
Curator picker - how to remove an added image?
I can't figure this out. After I've selected an image with the curator picker, and save the resource, there doesn't appear to be any way to remove said image again? I've clearly missed something super obvious, but I don't know what. Here's the code that sets up the picker for my categories:
CuratorPicker::make('hero_image_id')
->label('Hero image')
->relationship('heroImage', 'id')
->imageCropAspectRatio('16:9')
->imageResizeTargetWidth(1190)
->imageResizeTargetHeight(600)
CuratorPicker::make('hero_image_id')
->label('Hero image')
->relationship('heroImage', 'id')
->imageCropAspectRatio('16:9')
->imageResizeTargetWidth(1190)
->imageResizeTargetHeight(600)
Help?
34 replies
FFilament
Created by Oddman on 9/17/2023 in #❓┊help
Rows not showing in list view after modifying query
I have a weird problem. I added a scope to my Galaxy model that is applied for the list view. That code looks like the following:
public function table(Table $table): Table
{
return $table->modifyQueryUsing(function(Builder $query) {
$query->countStructures();
});
}
public function table(Table $table): Table
{
return $table->modifyQueryUsing(function(Builder $query) {
$query->countStructures();
});
}
The resulting query, looks like this:
select "galaxies".*, (select COUNT(sectors.id) from "sectors" where sectors.galaxy_id = galaxies.id) as "sectors", (select COUNT(systems.id) from "systems" where systems.galaxy_id = galaxies.id) as "systems", (select COUNT(celestial_bodies.id) from "celestial_bodies" where celestial_bodies.galaxy_id = galaxies.id and "celestial_bodies"."type" = ?) as "planets" from "galaxies" where "galaxies"."deleted_at" is null order by "galaxies"."id" asc limit 10 offset 0 ["planet"]
select "galaxies".*, (select COUNT(sectors.id) from "sectors" where sectors.galaxy_id = galaxies.id) as "sectors", (select COUNT(systems.id) from "systems" where systems.galaxy_id = galaxies.id) as "systems", (select COUNT(celestial_bodies.id) from "celestial_bodies" where celestial_bodies.galaxy_id = galaxies.id and "celestial_bodies"."type" = ?) as "planets" from "galaxies" where "galaxies"."deleted_at" is null order by "galaxies"."id" asc limit 10 offset 0 ["planet"]
This is all fine, and when I run the query in postgres, it shows the correct rows. But nothing is showing up in the list view (but the list view count is correct). There are no errors, no console errors, everything looks fine. Any ideas as to why this might be the case?
6 replies
FFilament
Created by Oddman on 8/19/2023 in #❓┊help
How to disable a form element on update
As per title, I have fields I only want available when creating a new resource.
5 replies
FFilament
Created by Oddman on 8/19/2023 in #❓┊help
How do I configure the user model to be something like "admin"
Looked over the docs, couldn't find it - wanting to use an Admin model, not User.
9 replies
FFilament
Created by Oddman on 8/12/2023 in #❓┊help
How should I handle a publishing platform regarding admins vs authors?
I have a single panel currently setup, and that panel has access to all resources, for admins/editors (with some policies in place). What about for authors? Authors wouldn't need, and can't have access to most of the resources there, so should I setup a separate panel with its own bespoke requirements and setup just for authors? In short, authors should really only have access to articles (only theirs), and be able to see comments.etc. and notifications regarding their own articles. Should I setup a separate panel for this that they can see? Or is there a better way?
10 replies