Help to build ui elements with bootstrap using laravel components
Using Composer
composer require cwsps154/laravel-settings
php artisan vendor:publish
You can use tag also
php artisan vendor:publish --tag=config --tag=components --tag=views --tag=migrations
Use this model CWSPS154\Settings\Models\Setting
in the AppServiceProvider
class and add below code in the boot method on you project.
public function boot()
{
if (!app()->runningInConsole()) {
$settings = cache()->remember(
'settings',
3600,
fn() => Setting::all()->keyBy('key')
);
View::share('settings', $settings);
}
}
Then you can use the settings with this code in anywhere in the blade pages
$settings['your-key-name']->value ?? $settings['your-key-name']->default