engrlaravel
3 weeks ago
149
4
Laravel

Laravel eloquent JOINS & Relationships issue

Posted 3 weeks ago by engrlaravel

I have below tables/models

Plan(id,created_by)
PlanPosition(id,plan_id,position_id)
Vacancy(id,position_id)

I have this relation in Plan

public function positions()
{
    return $this->hasMany('App\PlanPosition', 'plan_id');
}

Now i want to do the following

 select all records from first 2 tables where plan.created_by = 7

AND

AND is not exist in vacancy

Is there any cleaner way to do it in laravel?

Please sign in or create an account to participate in this conversation.