Laravel 4 - Jak używać, gdzie warunki dla kolumny relacji
Tego właśnie chcę, mam dwa stoły. jedna to „Restauracje”, a druga to „Usługi”.
Tabele są proste .. i relacje One-to-One. jak tam jest stół restauracyjnyid
, name
, slug
, itp. i inna tabela o nazwiefacilities
zid
, restaurant_id
, wifi
, parking
itp
Oto moje modele:
class Restaurant extends Eloquent {
protected $table = 'restaurants';
public function facilities() {
return $this->hasOne('Facilities');
}
}
class Facilities extends Eloquent {
protected $table = 'facilities';
public function restaurant() {
return $this->belongsTo('Restaurant');
}
}
Chcę to zrobićSelect * from restaurants r left join facilities rf on r.id=rf.restaurant_id where r.name = 'bbq' and rf.wifi != '1'
.
Jak użyć Eloquent, aby to zrobić?
ps. przepraszam za modyfikację zhttps://stackoverflow.com/questions/14621943/laravel-how-to-use-where-conditions-for-relations-column#= , ale mam podobny problem.