Closed cviebrock closed 8 years ago
Figured it out ... the line Service::observe(new CountCacheObserver());
needs to go in the boot()
method of the AppServiceProvider, not the register()
method.
I'll send a PR to update the docs to clarify that, if you don't mind.
I have a Category model that has many Services. My categories table has columns for _categoryid (the primary key) and _servicescount, among other fields. The services table has _serviceid (primary key) and _categoryid, among others.
My Service model looks something like:
Finally, in App/Providers/AppServiceProvider.php, I have in my
register()
method:When I create a new Service model, or edit an existing on, the _servicescount field on the corresponding Category model isn't increasing. Where did I goof?