Is there any way to conditionally call Lucid model hooks? #1427
Replies: 2 comments
-
Can you be more descriptive with your question? It is vague right now
|
Beta Was this translation helpful? Give feedback.
-
I have a model like below class Product extends Model {
static boot() {
super.boot();
this.addHook('afterFind', 'ProductHook.guarante');
this.addHook('afterFind', 'ProductHook.guarantees');
this.addHook('afterFind', 'ProductHook.userPrice');
this.addHook('afterFind', 'ProductHook.freeShipping');
this.addHook('afterFind', 'ProductHook.inStock');
this.addHook('afterFind', 'ProductHook.priceLevel');
this.addHook('afterFind', 'ProductHook.basePrice');
this.addHook('afterFind', 'ProductHook.offerType');
this.addHook('afterFind', 'ProductHook.colors');
}
} In the But the problem is I have a lot of route and use the product model on that. In some routes I need to use all of this hooks. but In some other and most of the time I need just two of them . How should it possible to use them and set them in controller. or If you have any new way or suggestion I should be glad to hear it and I like to know do you think about it to make |
Beta Was this translation helpful? Give feedback.
-
I have a model with hooks and need to call some hooks in some routes and didn't need to call those in some others hooks
How should it happend ?
Beta Was this translation helpful? Give feedback.
All reactions