%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /home/silvzytp/crm-ind-code/app/Providers/
Upload File :
Create Path :
Current File : /home/silvzytp/crm-ind-code/app/Providers/SettingServiceProvider.php

<?php

namespace App\Providers;
use App\Models\Setting;
use Illuminate\Support\Facades\App;
use Illuminate\Foundation\AliasLoader;
use Illuminate\Support\Facades\Config;
use Illuminate\Support\Facades\Schema;
use Illuminate\Support\ServiceProvider;

class SettingServiceProvider extends ServiceProvider
{
    /**
     * Register services.
     *
     * @return void
     */
    public function register()
    {
        $this->app->bind('settings', function(){
            return new Setting();
        });
        $loader = AliasLoader::getInstance();
        $loader->alias('Setting',Setting::class);
    }

    /**
     * Bootstrap services.
     *
     * @return void
     */
    public function boot()
    {
        if(!App::runningInConsole() && count(Schema::getColumnListing('settings'))){
            $settings = Setting::all();
            foreach ($settings as $setting) {
                Config::set('settings.'.$setting->key,$setting->value);
            }
        }
    }
}

Zerion Mini Shell 1.0