/** * Get all of the models from the database. Overrides the base behavior to * add the category slug as a condition. * * @param array $columns * An array of columns to access. * * @return \Illuminate\Database\Eloquent\Collection|static[] */ public static function all($columns = ['*']) { // If there's a defined taxonomy slug, attach that. $instance = new static(); if (isset($instance->taxonomy_slug) && $instance->taxonomy_slug) { // Return a constrained collection. $columns = is_array($columns) ? $columns : func_get_args(); return $instance->newQuery()->where('taxonomy', $instance->taxonomy_slug)->get($columns); } // Return the parent's behavior, if nothing is set. return parent::all($columns); }