n0tttrui
1030
2
Eloquent

Call to a member function connection() on null

Posted 2 years ago by n0tttrui

I get this error on this (Call to a member function connection() on null) code:

###SettingsServiceProvider.php

<?php

namespace App\Providers;

use Illuminate\Support\ServiceProvider;

use App\Setting;

class SettingsServiceProvider extends ServiceProvider
{
    /**
     * Bootstrap the application services.
     *
     * @return void
     */
    public function boot()
    {
        //
    }

    /**
     * Register the application services.
     *
     * @return void
     */
    public function register()
    {
        $setting = Setting::all();
        view()->share('setting', $setting);
    }
}

###config/app.php

'providers' => [
App\Providers\SettingsServiceProvider::class,
],

###Setting.php

<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class Setting extends Model
{
    protected $table = 'settings';

    protected $fillable = array('name_key', 'value');
}

can someone help me? thx!

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