PHP code example of ionutmilica / laravel-settings

1. Go to this page and download the library: Download ionutmilica/laravel-settings library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

ionutmilica / laravel-settings example snippets


$canRegister = settings('restrictions.register');

if (! $canRegister) {
	// do something
}

// Fetching with default value

$canRegister = settings('restrictions.register', false);

// Fetching and save the setting if it does not exist

$canRegister = settings('restrictions.register, false, true);


settings()->set('my-setting', 'some-value');

if (settings()->has('my-setting')) {
    // do something
}

settings()->forgot('my-setting');

settings()->set('the-answer', 42);
settings()->save();


use IonutMilica\LaravelSettings\SettingsContract;

class RegistrationController extends Controller {

    public function register(Request $request, SettingsContract $settings)
    {
        if ($settings->get('restrictions.registration')) {
        	return redirect()->back();
        }
        
        // Do something
    }
}