flex
Pivot-Table with Morph-Relation?
Hello,
I have a Contract Model with a ContractResource and a Cluster Model with ClusterResoruce. Now I have a pivot table betweem them called cluster_contract with some normal attributs. Working just fine to attach them, edit pivot columns, etc. No problems here.
But now, the pivot table clust_contract, has again a morph relation to the model "County". So, I have a table clustercontractable with cluster_contract_id, _type, _id, columns, etc..
In the contract's relation for clusters() am doing a using() on a ClusterContract class extending the Pivot class. Doing this also to add casts to the pivot attributes, which also worked fine.
But if I now, add the counties() morphedBy relation to the ClusterContract class and add the
Forms\Components\Select::make('counties')
->label('Landkreise')
->multiple()
->preload()
->relationship('counties', 'name'),
to the resource, I get the error Call to a member function getResults() on null
in vendor/filament/forms/src/Components/Select.php:889.
I made some debugging and the reason for this error is, that Filament tries to find the relation "counties" on the model "Cluster" and not on the pivot table "ClusterContract". Makes sense.
But... I also have fields in this resource like ::make('email'), etc.. and here Filament automatically detects, that I want to address the pivot's attribute email and not the Cluster attribute.
Is there a way to tell Filament, that with counties, I mean the relation on the ClusterContract table, and not on the Cluster table?
Thanks a lot!2 replies
Get Schema from Form for createOptionForm()I
Is it possible to get the schema from an exsiting Resource to pass it to createOptionForm() of another resource without reapting yourself or without chaging anything in the origin resoruce?
In Filament 2.0 I think there was getSchema() on Form class. Now it's gone.
Is there another option?
13 replies
Self-Registering Filament Plugins
Let's imagine I am developing a package cms (based on Filament). Now I want to offer an additional package called blog.
In my laravel project now I add the two dependencies cms and blog.
The cms has the FilamentServiceProvider to register the panel.
The blog package contains a Filament plugin.
Is there anyway, that the blog package registers it's BlogPlugin "itself" into the Filament panel?
So, both, the laravel project nor the cms package doesn't need to know anything about the blog package?
Thank you 🙂
16 replies
School-Class-Manager Usability-Problem
Let's imagine we have tool to manage school classes. Each school class has many students, documents, timetables, events and a lot more. All further tables have a school_class_id.
At the moment I see two options to make them managable in Filament:
1) All resources are linked in the filament menu. Problem: Clicking on students for exmaple would list all students of all classes.
2) I only link school classes in the menu and all other resources I show in the detail-view of the school class.
But if we now we have the scenario, that a teacher normally manages one school class at once, it would be awesome to set the current active school class (beside the avatar in filament for example) and clicking on "Students" in the menu only shows students of this active school class by default.
Is this possible with filament?
7 replies
Output a list/table in Resource's view-page without any Model
Hello!
I want to show a simple table in a resource's view-page. But it's not a relation and the data to show does not depend on a model.
Is there an easy way to do it in Filament v3?
Thank you!
8 replies
Register Resources from a Plugin without adding it as Plugin in Panel?
Hi, in v2 I used PluginServiceProvider::$resources to register new resources. So, I just needed to install the package and the resource was available.
While upgrading to v3 I'm extending PackageServiceProvider now, but the resources don't get registered:
Is there any option to register resources in v3 from a plugin without the need to register it in the "parent" panel (as this is in a package for me too)?
Thank you!
41 replies
How to handle records of different "type" and different fields depending on the type?
Hey! I have a simple model called "Visual". It has the fields
name
(string), type
(enum) and settings
(json). In a CMS the record should represent any type of visual objects like an image, a slider, a video, a chart, a pdf, whatever.. Each type has completely different fields which should be stored into settings
column. So for example image just have a FileUpload. A slider has multiple FileUploads, a chart may have just a Codefield to insert a iframe-code or whatever...
How can I use different fields depending on the selected type in the Select for "type"?
To may make it little bit more challenging (for me): For each of those visual types we have packages to only install only the types we need for the website. The packages register them self in a VisualTypeRegistry. A VisualType object has a getKey() ``getLabel()
and getSchema()
function. Building the type Select works well depending on the key and the label. But now I don't know how to tell filament to use the getSchema() for the selected type.25 replies
How to load my Resources, etc. in a Laravel Package?
Hello! I am currently developing a small Laravel CMS Package. I have some resources for pages, etc. Filament in general loads successfully (added Filament to the composer of the package). But my resources from the packages /src/Filament folder don't get loaded. My filament dashboard is just empty.
How can I define, that the package should also load my Resource files from the src/Filament folder?
16 replies