Get default value on config repository
This commit is contained in:
@@ -25,8 +25,8 @@ class ThemeComposer
|
|||||||
*/
|
*/
|
||||||
public function compose(View $view)
|
public function compose(View $view)
|
||||||
{
|
{
|
||||||
$view->with('themeBackgroundColor', Setting::get('style_background_color') ?: null);
|
$view->with('themeBackgroundColor', Setting::get('style_background_color'));
|
||||||
$view->with('themeTextColor', Setting::get('style_text_color') ?: null);
|
$view->with('themeTextColor', Setting::get('style_text_color'));
|
||||||
|
|
||||||
$viewData = $view->getData();
|
$viewData = $view->getData();
|
||||||
$themeView = array_only($viewData, preg_grep('/^theme/', array_keys($viewData)));
|
$themeView = array_only($viewData, preg_grep('/^theme/', array_keys($viewData)));
|
||||||
|
|||||||
@@ -45,11 +45,12 @@ class Repository
|
|||||||
* Returns a setting from the database.
|
* Returns a setting from the database.
|
||||||
*
|
*
|
||||||
* @param string $name
|
* @param string $name
|
||||||
|
* @param string $default
|
||||||
* @param bool $checkEnv
|
* @param bool $checkEnv
|
||||||
*
|
*
|
||||||
* @return string|null
|
* @return string|null
|
||||||
*/
|
*/
|
||||||
public function get($name, $checkEnv = true)
|
public function get($name, $default = null, $checkEnv = true)
|
||||||
{
|
{
|
||||||
// if we've not loaded the settings, load them now
|
// if we've not loaded the settings, load them now
|
||||||
if (!$this->settings) {
|
if (!$this->settings) {
|
||||||
@@ -65,6 +66,8 @@ class Repository
|
|||||||
if ($checkEnv) {
|
if ($checkEnv) {
|
||||||
return $this->settings[$name] = env(strtoupper($name));
|
return $this->settings[$name] = env(strtoupper($name));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return $default;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -142,7 +142,7 @@ if (!function_exists('formatted_date')) {
|
|||||||
*/
|
*/
|
||||||
function formatted_date($date)
|
function formatted_date($date)
|
||||||
{
|
{
|
||||||
$dateFormat = Setting::get('date_format') ?: 'jS F Y';
|
$dateFormat = Setting::get('date_format', 'jS F Y');
|
||||||
|
|
||||||
return (new Date($date))->format($dateFormat);
|
return (new Date($date))->format($dateFormat);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user