Enhance settings performance queries
This commit is contained in:
@@ -2,7 +2,6 @@
|
||||
|
||||
namespace CachetHQ\Cachet\Models;
|
||||
|
||||
use ErrorException;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
/**
|
||||
@@ -27,32 +26,4 @@ class Setting extends Model
|
||||
* @var string[]
|
||||
*/
|
||||
protected $attributes = ['value' => ''];
|
||||
|
||||
/**
|
||||
* Returns a setting from the database.
|
||||
*
|
||||
* @param string $settingName
|
||||
* @param bool $checkEnv
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public static function get($settingName, $checkEnv = true)
|
||||
{
|
||||
$setting = null;
|
||||
|
||||
try {
|
||||
$setting = self::whereName($settingName)->first()->value;
|
||||
} catch (ErrorException $e) {
|
||||
if ($checkEnv) {
|
||||
$env = getenv(strtoupper($settingName));
|
||||
if (!$env) {
|
||||
return $env;
|
||||
}
|
||||
}
|
||||
|
||||
return $setting;
|
||||
}
|
||||
|
||||
return $setting;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user