clearEntityTaggedCache(); }); static::deleted(function ($entity) { $entity->clearEntityTaggedCache(); }); } public static function queryWithoutEagerRelations() { return (new static)->newQueryWithoutEagerRelations(); } public function newQueryWithoutEagerRelations() { return $this->registerGlobalScopes( $this->newModelQuery()->withCount($this->withCount) ); } public function clearEntityTaggedCache() { Cache::tags($this->getTable())->flush(); } /** * Register a new active global scope on the model. * * @return void */ public static function addActiveGlobalScope() { static::addGlobalScope('active', function ($query) { $query->where('is_active', true); }); } }