I have three tables:
Member
MemberBranch
Branch
The Member
can have many Branch
es through MemberBranch
. And a Branch
can have many Member
s etc.
What I want to be able to do is get a count of how many members a branch has.
so
$branch = Branch::find_by_title('London');
$branch->number_of_members; // Will equal how many members have the branch through MemberBranch
How would I go about doing this?