findByIdentifier($this->code); if ($pluginObj) { $pluginInfo = $pluginObj->pluginDetails(); foreach ($pluginInfo as $attribute => $info) { $this->{$attribute} = Lang::get($info); } if ($this->is_disabled) { $manager->disablePlugin($this->code, true); } else { $manager->enablePlugin($this->code, true); } $this->disabledBySystem = $pluginObj->disabled; if (($configDisabled = Config::get('cms.disablePlugins')) && is_array($configDisabled)) { $this->disabledByConfig = in_array($this->code, $configDisabled); } } else { $this->name = $this->code; $this->description = Lang::get('system::lang.plugins.unknown_plugin'); $this->orphaned = true; } } /** * Returns true if the plugin should be updated by the system. * @return bool */ public function getIsUpdatableAttribute() { return !$this->is_disabled && !$this->disabledBySystem && !$this->disabledByConfig; } /** * Only include enabled plugins * @param $query * @return mixed */ public function scopeApplyEnabled($query) { return $query->where('is_disabled', '!=', 1); } /** * Returns the current version for a plugin * @param string $pluginCode Plugin code. Eg: Acme.Blog * @return string */ public static function getVersion($pluginCode) { if (self::$versionCache === null) { self::$versionCache = self::lists('version', 'code'); } return isset(self::$versionCache[$pluginCode]) ? self::$versionCache[$pluginCode] : null; } /** * Provides the slug attribute. */ public function getSlugAttribute() { return self::makeSlug($this->code); } /** * Generates a slug for the plugin. */ public static function makeSlug($code) { return strtolower(str_replace('.', '-', $code)); } }