I\'m trying to store all my settings from my settings
table into a global variable, but I\'m stucked now(I have no idea what\'s the next step), this is my actua
You can store the data in the database just like you do it normally in Laravel. \App\Setting::create()
, \App\Setting::new()
and other methods.
For using the values in blade, you can do {{\App\Setting::where('name','title')->pluck('value')}}
And, you can also use scopes for this.
class Setting extends Model
{
public function scopeFor($query, $settingName)
{
return $query->where('name', $settingName);
}
}
then you could use \App\Setting::for('title')->pluck('value')