model hasManyThrough relationship using a pivot model – Laravel
I have the following models/tables: branch: id - integer department: id - integer teacher: id - integer branch_department_id - integer branch_department: id - integer branch_id - integer department_id - integer each branch has many departments through the pivot table branch_department…