Closed jdgriffith closed 9 years ago
Is it possible to set the save method to a Closure?
Hmmm, no.
We decided to remove that ability in 3.0. Instead, we recommend you use a custom ModelStore class.
Just pass your custom instance as the first param when constructing a factory muffin object.
Well bum. I didn't follow your last comment. Do you have an example?
Extend our model store class, override the stuff you want changing, then when you do new FactoryMuffin()
, instead do new FactoryMuffin(new YourStoreClass())
.
Ok thanks.
We decided that was a better way to do things than have a hacky override using closures. :)
I do not see the Model Store class you are referencing. Are you referencing the Definition class?
Perfect! Much less hacky and OO. I must be on a different version. Will check my composer file. Thanks for all the responses!
If your using v2, then you can use a closure to customize stuff. See https://github.com/thephpleague/factory-muffin/tree/2.1#additional-customisation.
Ya, that's what I was doing before in v2. Honestly, I was hoping the groups and definitions were a little better in v3. It appears you can set a group off of a definition but can't search for all models belonging to a group. I suppose I could code that easily though.
Is it possible to set the save method to a Closure? I was doing this in a previous version and it worked pretty well. I am trying to save models to a mongo instance. I was able to set the callable maker but could not find the same functionality with the save.