PHP code example of surya / laravel-settings

1. Go to this page and download the library: Download surya/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/ */

    

surya / laravel-settings example snippets


'providers' => [
    Surya\Setting\SettingServiceProvider::class,
]

'aliases' => [
    'Setting' => Surya\Setting\Facades\Setting::class,
]

return [
    'site_name'     => [
        'type'      => 'text',
        'default'   => 'Laravel',
        'label'     => 'Site Name'
    ],
    'genre'         => [
        'type'      => 'radio',
        'default'   => 'male',
        'label'     => 'Genre',
        'options'   => [
            'male'      => 'Male',
            'female'    => 'Female'
        ]
    ]
]

@rendersettings('general')

<form method="POST" action="#yoursettingsaveroute">
    {!! csrf_field() !!}
    @rendersettings('general')
    <input type="submit" value="Save">
</form>

use Setting;
use Illuminate\Http\Request;

class SettingController extends Controller
{
    public function save(Request $request)
    {
        Setting::save($request->except('_token'));
        return redirect('your.view');
    }
}

settings('group.key');

Setting::get('group.key');

Setting::getSettingProp('group.key.default')

setting('group.key.default')

Setting::exists('group', 'key)

settingExists('group', 'key')

<div class="form-group">
    <label for="email-{{ $i }}">{{ $label }}</label>
    <input type="email" id="email-{{ $i }}" class="form-control" value="{{ $value }}" name="value[]">
</div>

return [
    'primary_user'    => [
        'type'  => 'select',
        'label' => 'Select a Primary User',
        'source'    => App\User::class,
        'show_label'     => 'email'
    ],
]

'example_switch'    => [
        'type'  => 'switch',
        'default'   => 0,
        'label' => 'Switch Example',
    ]

'    'type'      => 'check',
    'default'   => ['logo', 'profile'],
    'label'     => 'Your website    'identity'  => 'Your identity'
    ]
],

php artisan vendor:publish --provider="Surya\Setting\SettingServiceProvider" --tag="migrations"

php artisan migrate

php artisan vendor:publish --provider="Surya\Setting\SettingServiceProvider" --tag="views"