For a model I have a complicated scope condition like so:
class Foo {
public static function scopeActive(Builder $query) {
// Some complicated query
}
}
This complicated condition will select all the records in Foo that are considered active.
I have another class like so:
class Bar {
public foos() {
return $this->hasMany(Foo::class);
}
}
Which means the Bar model has many Foo models.
Now if I wanted to get all the Bar models as well as all the active Foo models that belong to it, I can do the following:
Bar::with(['foo', function (HasMany $query) {
$query->active();
})->get();
However, how can I write a query that gives me all the Bar records that are NOT active.
from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2l3WTGc
via IFTTT
Aucun commentaire:
Enregistrer un commentaire