Answer the question
In order to leave comments, you need to log in
How to link tables through two intermediate ones?
The essence is this
There are four tables: Habitation, HabitationPlace, Place and Room
They are connected as follows
//Habitation и HabitationPlace
public function places() {
return $this->hasMany('App\Habitationplace', 'habitation_id', 'id');
}
//HabitationPlace и Place
public function place()
{
return $this->hasOne('App\Place', 'id', 'place_id');
}
//Place и Room
public function room()
{
return $this->hasOne('App\Room', 'id', 'room_id');
}
{
$level_idd = $request['level']+2;
$level_id = DB::table('room')->where('level_id', '=', $level_idd)->get();
$habitation = Habitation::with(["places"])
->where('status','=','saselen')
->whereDate('dogovor_date','>=',$start_date)
->whereDate('dogovor_date','<=',$date_end)
->where('documenul_id','=',$request['documenuls'])
->get();
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question