In this lesson we will learn how to add operation hooks to our models. In the Product model we will create a
before safe observer that will check if the category we want to add the product to exists.
In our Category model we will create a
before delete observer to prevent categories from being deleted when they have products.
We will create a unit test to verify that both of these operation hooks work as expected.
why the product hook returns next() and the category model does not?
Hello! It seems we can do the same with an Async Validator, is there an advantage using a Hook over it ? What I can see is: