Namespaced models and refactored filters

This commit is contained in:
Graham Campbell
2015-01-02 00:18:19 +00:00
parent 15a6694865
commit 0ccb5e289c
66 changed files with 310 additions and 195 deletions

43
src/Models/Setting.php Normal file
View File

@@ -0,0 +1,43 @@
<?php
namespace CachetHQ\Cachet\Models;
use Illuminate\Database\Eloquent\Model;
class Setting extends Model
{
/**
* The fillable properties.
*
* @var string[]
*/
protected $fillable = ['name', '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;
}
}