topclaudy / compoships

Multi-columns relationships for Laravel's Eloquent ORM
MIT License
1.1k stars 130 forks source link

Where not working #162

Open Daniel-Monroy opened 11 months ago

Daniel-Monroy commented 11 months ago

Hi, Guys.

I am facing a problem, how can I make a relationship like the following?

function a() {
    return $this->hasMany(ModelRelated::class, ['employee_id', 'level_id'], ['employee_id', 'level_id'])
        ->where(function ($q) {
            $q->whereColumn('parent_table.start_date', '<=', 'related_table.start_date')
                ->whereColumn('parent_table.end_date', '>=', 'related_table.end_date');
        });
}
parallels999 commented 11 months ago

That's not how things work