/** * Allows filtering for specifc sources * * @param October\Rain\Database\Builder $query QueryBuilder * @param array $sources List of source ids * @return October\Rain\Database\Builder */ public function scopeFilterSources($query, array $sources = []) { return $query->whereHas('source', function ($q) use($sources) { $q->whereIn('id', $sources); }); }
/** * Returns models that have not yet started * * @param October\Rain\Database\Builder $query * @return October\Rain\Database\Builder */ public function scopeIsUpcoming($query) { return $query->where(function ($model) { $model->whereNotNull('start_at')->where('start_at', '>', Carbon::now()); }); }