Optimistic Locking with related tables


Let’s say I have two tables: one for jobs and one for jobs functions. In the job functions list, we have id, jobfunction and job_id. Job_id is the relation between a jobfunction and the parent job description. I also have two differents forms, one is for the job description and one for adding/deleting jobs functions. We are in a conccurent context and I would like to have optimistic locking implemented so that whenever a user update the list of job functions for a given job, he/she can’t do that if he/she does not have the latest version of the job function list.

In that context, the locking must be set on the parent record, not on the child being added or deleted. Is there any simple way to do this in yii2. Optimistic locking is already implemented for the job description record (first form) followning instructions from here and OptimisticLock(). I was thinking of making a fake update of the job description record using [url="http://www.yiiframework.com/doc-2.0/yii-db-baseactiverecord.html#beforeSave()-detail"]beforeSave/url and beforeDelete method().

Is there any other way/ideas/best practices?