Enhance settings performance queries

This commit is contained in:
Joseph Cohen
2015-01-14 17:19:41 -06:00
parent 494bcd9adb
commit 4f250db260
10 changed files with 128 additions and 35 deletions

View File

@@ -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;
}
}