Support the ongoing development of Laravel.io →
posted 7 years ago
Eloquent
Last updated 2 years ago.
0

Something like this seems to work, not final though

public function otherDistrictCountRelation()
{
    return $this->hasOne('Registration', 'event_id')
        ->join('user_attributes', function ($join) {
            $join->on('user_attributes.internalKey', '=', 'user_id')->where('user_attributes.centre_id', '=', 0);
        })
        ->selectRaw('event_id, count(*) as count')->groupBy('event_id');
}
0

Sign in to participate in this thread!

Eventy

Your banner here too?

Cipa cipa Joined 11 Dec 2017

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.