I'm newbie and I'm learning laravel 5.2, I have a blog that I'm making with laravel and I have a table in the database called "settings" and Here's the migration file of it:
public function up()
{
Schema::create('settings', function (Blueprint $table) {
$table->increments('id');
$table->string('site_name');
$table->text('site_description');
$table->string('about_head');
$table->text('about_description');
$table->text('about_body');
$table->timestamps();
});
}
I entered data to this table, now I wanna pass these data to all controllers and all methods. I found that the best way to do that is to make a custom configuration file on App\Config folder. So I made a file called "custom" and I tried to access the database to get data from settings table and here's the custom config:
<?php
use Illuminate\Support\Facades\Config;
use App\Setting;
$setting = Setting::find(1);
return array(
'site_name' => $setting->site_name,
'site_description' => $setting->site_description,
'about_head' => $setting->about_head,
'about_description' => $setting->about_description,
'about_body' => $setting->about_body,
);
But I got that error on my laravel root directory
Fatal error: Call to a member function connection() on null in C:\xampp\htdocs\myblog\vendor\laravel\framework\src\Illuminate\Database\Eloquent\Model.php on line 3280
Have any idea how to fix it? or at least do you know another solution to pass my site settings data to all controllers, methods and views?
Thanks for your time.