I have three models Employer , Job, and Transaction
Employer can have many Job
Job can have many Transaction
I am trying to use ActiveRecord to get all Employer that do not have a Transaction record.
Within my Employer model, I have defined relations to find all jobs and transactions linked to this employer:
/**
* @return \yii\db\ActiveQuery
*/
public function getJobs() {
return $this->hasMany(Job::className(), ['employer_id' => 'employer_id']);
}
/**
* @return \yii\db\ActiveQuery
*/
public function getTransactions() {
return $this->hasMany(Transaction::className(), ['job_id' => 'job_id'])->via("jobs");
}
Any ideas on the best way to do this?