Setting Module
To use a setting you can inject the setting interface into your method/constructor.
use Modules\Setting\Contracts\Setting;
...
/**
* @var Setting
*/
private $setting;
public function __construct(Setting $setting)
{
$this->setting = $setting;
}
Once this is done you can use the interface to get a setting, in a given locale. Since settings can be translatable or not, you can optionally specify the language.
$siteName = $this->setting->get('core::site-name', locale())
$postsPerPage = $this->setting->get('blog::posts-per-page');
In your views you can call the @setting()
blade directive.
@setting('core::site-name');
// Get the setting value in a specific locale
@setting('core::site-name', 'fr');
// Set a custom default value
@setting('core::site-name', null, 'Default name');
In your views or any other class you can directly use the setting()
function.
To get the site name setting in the core module:
{{ setting('core::site-name') }}
Depreciated.
In views you can use the Setting
facade with the get()
method.
To get the site name setting in the core module:
{{ Setting::get('core::site-name') }}