$patients = Patient::orWhere('surname', $request->surname)
->orWhere('first_name', $request->first_name)
->orWhere('second_name', $request->second_name)
->orWhere('birthday', $request->birthday)
->orderBy('surname')
->orderBy('first_name')
->orderBy('second_name')
->orderBy('birthday');
foreach($passports as $passport){
$consultations = Consultation::orWhere($patients->id)->orderBy('day_consultation');
}
class Patient extends Model
{
public function consultations()
{
return $this->hasMany('App\Consultation');
}
public function passports()
{
return $this->hasMany('App\Passport');
}
}
class Consultation extends Model
{
public function patient()
{
return $this->belongsTo('App\Patient');
}
}
class Passport extends Model
{
public function patient()
{
return $this->belongsTo('App\Patient');
}
}