Aronaman
1 month ago
212
2
Laravel

retrieve value using helping method config()

Posted 1 month ago by Aronaman

i register setting service provider and retrieve value from settings table using helping method config() , it's working on other blade files, but when I try on email.blade not showing up??

SettingServiceProvider

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

    }

    /**
     * Bootstrap services.
     *
     * @return void
     */
    public function boot()
    {
         // only use the Settings package if the Settings table is present in the database
    if (!\App::runningInConsole() && count(Schema::getColumnListing('settings'))) {
        $settings = Setting::all();
        foreach ($settings as $key => $setting)
        {
            Config::set('settings.'.$setting->key, $setting->value);
            Config::set('settingsImg.'.$setting->key, $setting->multi_img);
        }
    }

    }
}

on my config.app.php

'providers' => [
 App\Providers\SettingServiceProvider::class,

    ],

then on my email blade, why settings not working and app.name working?

Thanks,<br>{{config('settings.seo_meta_description')}} // null 
{{ config('app.name') }}// it is working 

Please sign in or create an account to participate in this conversation.