Unverified Commit 6a34661b authored by Nicolas Widart's avatar Nicolas Widart Committed by GitHub

Merge pull request #516 from tranfuga25s/AddSettingsDirective

Add settings directives
parents ca13b958 aa191d04
...@@ -27,6 +27,21 @@ final class SettingDirective ...@@ -27,6 +27,21 @@ final class SettingDirective
return setting($this->settingName, $this->locale, $this->default); return setting($this->settingName, $this->locale, $this->default);
} }
/**
* Check if a setting is set and is not empty
* @param array $arguments
* @return boolean
*/
public function has($arguments)
{
$value = $this->show($arguments);
if (empty($value)) {
return false;
}
return true;
}
/** /**
* @param array $arguments * @param array $arguments
*/ */
......
...@@ -94,8 +94,17 @@ class SettingServiceProvider extends ServiceProvider ...@@ -94,8 +94,17 @@ class SettingServiceProvider extends ServiceProvider
if (app()->environment() === 'testing') { if (app()->environment() === 'testing') {
return; return;
} }
$this->app['blade.compiler']->directive('setting', function ($value) { $this->app['blade.compiler']->directive('setting', function ($value) {
return "<?php echo SettingDirective::show([$value]); ?>"; return "<?php echo SettingDirective::show([$value]); ?>";
}); });
$this->app['blade.compiler']->directive('hasSetting', function($value) {
return "<?php if (SettingDirective::has([$value])) : ?>";
});
$this->app['blade.compiler']->directive('endHasSetting', function() {
return "<?php endif; ?>";
});
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment