Laravel 4 - Wie verwende ich where-Bedingungen für die Spalte der Relation?
Das ist was ich will, ich habe zwei Tische. Eines ist "Restaurants" und andere ist "Einrichtungen".
Die Tabellen sind einfach und Eins-zu-Eins-Beziehungen. Als gäbe es einen Restauranttisch mitid
, name
, slug
usw und ein anderer Tisch genanntfacilities
mitid
, restaurant_id
, wifi
, parking
, usw
Hier sind meine Modelle:
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');
}
}
Ich möchte das gerne tunSelect * from restaurants r left join facilities rf on r.id=rf.restaurant_id where r.name = 'bbq' and rf.wifi != '1'
.
Wie benutzt man Eloquent, um das zu tun?
ps. Entschuldigung für die Änderung vonhttps://stackoverflow.com/questions/14621943/laravel-how-to-use-where-conditions-for-relations-column#= , aber ich habe das ähnliche problem.