PHP code example of sashalenz / laravel-settings-ui
1. Go to this page and download the library: Download sashalenz/laravel-settings-ui 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/ */
sashalenz / laravel-settings-ui example snippets
namespace App\Settings;
use SashaLenz\SettingsUi\Contracts\DeclaresSettings;
use SashaLenz\SettingsUi\Schema\Field;
use SashaLenz\SettingsUi\Schema\Group;
final class GeneralSettings implements DeclaresSettings
{
public function schema(): Group
{
return Group::make('general')
->label('General Settings')
->icon('heroicon-o-cog')
->fields([
Field::text('site_name')
->label('Website Name')
->default('My App')
->rules(['
use SashaLenz\SettingsUi\Facades\Settings;
public function boot(): void
{
Settings::register([
\App\Settings\GeneralSettings::class,
]);
// Or discover all settings across domain modules:
Settings::discover([
app_path('Domain/*/Settings'),
]);
}
// Stored database value automatically overlays config file default:
$siteName = config('general.site_name');
// Or using the Settings facade:
$siteName = Settings::get('general.site_name');
use SashaLenz\SettingsUi\Database\Seeders\SettingsSeeder;
class DatabaseSeeder extends Seeder
{
public function run(): void
{
$this->call(SettingsSeeder::class);
}
}
use SashaLenz\SettingsUi\Facades\Settings;
Route::prefix('admin')->middleware(['web', 'auth'])->group(function () {
Settings::routes();
});