更新时间:2022-10-23 21:24:55
I normally override newQuery()
for this. newQuery()
is the method that Eloquent use to construct a new query.
class News extends Eloquent {
public function newQuery($excludeDeleted = true) {
return parent::newQuery($excludeDeleted)
->where(status, '=', 1);
}
}
Now your News::all()
will only output your news with status = 1.