Mam tabele status
ID | name |
---|---|
1 | nowy |
2 | odwolany |
Mam tabele wizyty (visit)
ID | pacjent_id | status_id
---------------- | -------------------
1 | 1 | 1
2 | 3 | 2
W modelu wizyty mam
public function status() {
return $this->belongsTo('App\Statuses', 'id', 'status_id');
}
W modelu statusy mam
public function visit() {
return $this->hasOne('App\Visit');
}
Teraz chce wyjac zapytanie
Visit::where('dict_statuses_id', 1)
ale żeby w nim było pole np status_name i żeby to pole zawierało wartość name z tabeli statusy. jak to zrobić ?