Post::model() - quick instantiation #48794
Unanswered
marknuyens
asked this question in
Ideas
Replies: 1 comment 8 replies
-
So, what's the difference to |
Beta Was this translation helpful? Give feedback.
8 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello everyone,
I would like to contribute a potential solution for quickly constructing a class using a new static
model()
method. Straight-forward, but has proven to be useful, especially for "method chaining".It's actually similar to the static
make()
method for Json Resources.I've been using this utility function myself and it has served me well in a couple of scenarios, mostly whenever I just wanted the model's primary key or other kind of properties that were not related to its data.
Although mine originally didn't support the
$attributes
parameter, I would imagine this could be beneficial too.Anyway, would love to to hear your thoughts!
Beta Was this translation helpful? Give feedback.
All reactions