/** * Bootstrap the application services. * * @return void */ public function boot() { foreach ($this->cachedModels as $cachedModel) { $closure = function ($model) { if ($model instanceof Cacheable) { foreach ($model->getCacheKeys() as $key) { $this->app['cache.store']->forget($key); } } }; $cachedModel::saved($closure); $cachedModel::deleted($closure); } Extension::saved(function ($model) { $this->app['cache.store']->forget('extension.' . $model->id); $this->app['cache.store']->forget('extensions.widgets'); $this->app['cache.store']->forget('extensions.all'); }); Extension::deleted(function ($model) { $this->app['cache.store']->forget('extension.' . $model->id); $this->app['cache.store']->forget('extensions.widgets'); $this->app['cache.store']->forget('extensions.all'); }); }
/** * Get the query object to be processed by datatables. * * @return \Illuminate\Database\Query\Builder|\Illuminate\Database\Eloquent\Builder */ public function query() { $users = Extension::query(); return $this->applyScopes($users); }
/** * Register an extension. * * @param array $attributes * @return $this * @throws \Exception */ public function register(array $attributes) { $validator = $this->getValidationFactory()->make($attributes, ['type' => 'required', 'name' => 'required', 'parameters.class' => 'required_if:type,widget', 'parameters.templates' => 'required_if:type,widget', 'parameters.template' => 'required_if:type,menu']); if ($validator->fails()) { throw new InvalidManifestException("Invalid manifest file detected!"); } $extension = new Extension(); $extension->type = $attributes['type']; $extension->name = $attributes['name']; if (isset($attributes['protected'])) { $extension->protected = $attributes['protected']; } if (isset($attributes['parameters'])) { $extension->parameters = $attributes['parameters']; } $extension->manifest = json_encode($attributes); $extension->save(); return $this; }