Model Observers

The use of model observers has been used in several places of the app to reduce error for missing mandatory tasks that need to be invoked upon creation/modification/deletion of a model.

It is crucial to know where these are used and what their purposes are, as it is not clear when an observer is being invoked due to it working off of model events (no reference to the observer can be found within the model class itself).

Below are the observers for the models along with what their purposes are.

Collection

Event

Action

Event

Action

created

Update the order for all other collections of the same type.

updating

Update the order for all other collections of the same type.

updated

Touch the related services (to synchronise with the search index).

deleting

Delete the child collectionTaxonomies records.

deleted

Update the order for all other collections of the same type.

CollectionTaxonomy

Event

Action

Event

Action

created

Touch the related services (to synchronise with the search index).

deleted

Touch the related services (to synchronise with the search index).

File

Event

Action

Event

Action

deleted

Remove the physical file from disk.

Location

Event

Action

Event

Action

updated

Touch the related services (to synchronise with the search index).

deleting

Delete the child updateRequests records.

 

Delete the child serviceLocations records.

deleted

Touch the related services (to synchronise with the search index).

Organisation

Event

Action

Event

Action

created

Make all Global Admins an Organisation Admin for the created organisation.

updated

Touch the related services (to synchronise with the search index).

deleting

Delete the child userRoles records.

 

Delete the child updateRequests records.

 

Delete the child services records.

Referral

Event

Action

Event

Action

creating

Create a unique reference for the referral.

deleting

Delete the child statusUpdates records.

Report

Event

Action

Event

Action

deleted

Delete the associated file record.

ServiceLocation

Event

Action

Event

Action

created

Touch the related services (to synchronise with the search index).

deleting

Delete the child updateRequests records.

 

Delete the child regularOpeningHours records.

 

Delete the child holidayOpeningHours records.

deleted

Touch the related services (to synchronise with the search index).

Service

Event

Action

Event

Action

created

Make all Organisation Admins for the service's organisation a Service Admin and Service Worker for the created service.

deleting

Delete the child updateRequests records.

 

Delete the child userRoles records.

 

Delete the child referrals records.

 

Delete the child serviceLocations records.

 

Delete the child serviceCriterion records.

 

Delete the child socialMedias records.

 

Delete the child usefulInfos records.

 

Delete the child serviceTaxonomies records.

ServiceTaxonomy

Event

Action

Event

Action

created

Touch the related services (to synchronise with the search index).

deleted

Touch the related services (to synchronise with the search index).

Taxonomy

Event

Action

Event

Action

created

Update the order for all other taxonomies with the same parent.

updating

Update the order for all other taxonomies with the same parent.

updated

Touch the related services (to synchronise with the search index).

deleting

Delete the child collectionTaxonomies records.

 

Delete the child serviceTaxonomies records.

 

Delete the child children records.

deleted

Update the order for all other taxonomies with the same parent.

UpdateRequest

Event

Action

Event

Action

created

Send a notification to the submitter, confirming their submission.

 

Send a notification to the Global Admins, notifying them of the new update request.

 

Remove same fields for other pending update requests.

 

Delete pending update requests with an empty data object.