How do I access / create relationships in custom actions that uses the createOptionForm method.
I have a custom action, that enables me to create a resource from another resources view. In this instance, I am wanting to create a project from the view contact page.
Here is the
Step
for my action so far:
Here is the error I am getting when trying to create my project Call to a member function isRelation() on null
Initially I thought I could create a method within the model to satisfy this but I was wrong.
So my question is; how can implement the above so that the isRelation() method is satisfied?4 Replies
The method
isRelation()
comes from Laravel and not Filament: https://github.com/laravel/framework/blob/6da5093aa672d26d0357b3569d8b3b426673dc61/src/Illuminate/Database/Eloquent/Concerns/HasAttributes.php#L566
But it needs debugging to find out which model of yours causes this issue: customer, project or project type, and at which point. I think it would require your full form code with all the steps to understand the full picture.
You're saying the error happens when you're trying to create a PROJECT? Then where is the code to save the project model? Or did you mean a project TYPE? Or a customer? Unclear to me, sorry.GitHub
framework/src/Illuminate/Database/Eloquent/Concerns/HasAttributes.p...
The Laravel Framework. Contribute to laravel/framework development by creating an account on GitHub.
My apologies if I described my issue unclearly.
The snippet of code I shared, is for when I create a
project
from a contacts
detail view.
I have my contact, who currently has 0 projects. I want to be able to add a project for the contact
- I have a custom widget, with an action defined that allows me to do so.
However, I have an issue when it comes to project types and the reason I thought it was filament is when I get this error Call to a member function isRelation() on null
it points me to this part of my code:
<x-filament-actions::modals/>
It only errors if I uncomment the following line:
->relationship('projectType', 'type')
This code is exactly as it is in my ProjectResource, and I have a method on the Project model for projectType
but it is is only when I lift the code and move it to my custom widget that it breaks.
Does that help explain the issue a little better?
I am having a look throught that link now.Yeah, understand much better now, thanks. So it's one of those typical cases of a simple Filament function used on top of several not-so-simple other functions and then there's a conflict or even incompatibility. These are possible to debug only by experiment and trial and error, not sure if possible to guess the solution here on discord, sorry.
That's okay thank you, I will try my hand at debugging it further and seeing if it is indeed compatiable, hopefully so!