Little lost on generating resource from a vendor model
So the command above would generate a resource from the Customer model, but what if the model was inside a vendor package?
19 Replies
I would create a model and extend the one on vendor folder. Then the resource would be linked to the one I created
Yeah that works, but also isn't efficient in the case I am after, as it would mean extending every model we have in packages to then generate resources, if you know what I mean?
Yeah I see, I think there's a property in the resource to tell which model to use. Let me check
Yeah cool, I just couldnt find anything in the documentation so not sure im looking in the right place
protected static ?string $model = null;
You put that on the resource you created and link it to the model you want
So I cant use the --generate command to get all my table and form info from the model filalbles
If theres a param on the command to select the model you can, otherwise I think not
Darn
If you have the time or know how maybe it's a nice feature for a PR
I would like to think so, but im not smart enough for that π€£
Ahaha same
Did you try name spacing the model with the generate command?
Something like
Package\\Models\\Model
I didnt try with double \, Ill give that a go
Nah, that still hasn't picked up my Profile Model.
php artisan make:filament-resource \Arch\User\Models\Profile --generate
It's looking like this: use App\Models\Arch\User\Models\Profile;
yea, looking at the code. it doesn't look possible to do this in this way. For now, i would do as others said and extend the package model for the generate command, then you can just delete the local model and update it's references in the Resources after it's generated. I know it's not optimal, but would still be quicker that building them by hand.
Think Im closing in on working it in the code at the moment, if I can get it to something alright, Ill submit it as a PR, just im a junior dev so dont wanna contribute when it could be done better
don't worry about being a Jr. π
that's just a title assigned to you by a company.
Is also very much my skill level π€£
Just working around with policies now, as my Profile model that I am using has a policy but doesn't return booleans (which I think may just be bad practice on my end)
I made a PR but since it was a small change, it may be easier to just flag it as a feature request, as it works locally but not sure if it's gonna be needed else where, as I've only used it in my use case
I think a PR is good because it offers the ability for other non filament packages.
Cool, well thats submitted π