Company hasMany
SectorCompany
SectorCompany belongsTo
Company
SectorCompany hasMany
Employee
Officer belongsTo
SectorCompany
With this data in hand, how do I count how many officials with id_status = 1 are allocated to sectors of type="Administrative" ? I tried the way below but it did not work and I think I'm far from right.
{{ $empresa->SetorEmpresa->where('tipo', 'Administrativo')->Funcionario->where('id_status', 1)->count() }}
I'm using Laravel 5.1 and this data will be loaded into a view from the Enterprise object.