title: Laravel - Set global variable from settings table
body: <p>I'm trying to store all my settings from my <code>settings</code> table into a global variable, but I'm stucked now(I have no idea what's the next step), this is my actual model and seeder:</p>
  
  <p>model - Settings.php</p>
  
  <pre><code>class Setting extends Model
  {
      protected $table = 'settings';
  
      public $timestamps = false;
  
      protected $fillable = [
          'name',
          'value',
      ];
  }
  </code></pre>
  
  <p>seeder - SettingsTableSeeder.php</p>
  
  <pre><code>class SettingsTableSeeder extends Seeder
  {
      public function run()
      {
  
          $settings = [
              ['name' =&gt; 'title', 'value' =&gt; ''],
              ['name' =&gt; 'facebook', 'value' =&gt; ''],
              ['name' =&gt; 'twitter', 'value' =&gt; ''],
              ['name' =&gt; 'instagram', 'value' =&gt; '']
          ];
  
          foreach($settings as $setting){
              \App\Setting::create($setting);
          }
      }
  }
  </code></pre>
  
  <p>How can I store all the data inside the settings table and make then acessible from blade, or any controller or view?</p>
  
  <h2>Edit</h2>
  
  <hr>
  
  <p>Now, my question is, how can i update a single or multiple value(s) from a form?</p>
  
  <p>I have set this up:</p>
  
  <p>My route:</p>
  
  <pre><code>Route::put('/', ['as' =&gt; 'setting.update', 'uses' =&gt; 'Admin\AdminConfiguracoesController@update']);
  </code></pre>
  
  <p>My Admin\AdminConfiguracoesController:</p>
  
  <pre><code>class AdminConfiguracoesController extends AdminBaseController
  {
      private $repository;
  
      public function __construct(SettingRepository $repository){
          $this-&gt;repository = $repository;
      }
  
      public function geral()
      {
          return view('admin.pages.admin.configuracoes.geral.index');
      }
  
      public function social()
      {
          return view('admin.pages.admin.configuracoes.social.index');
      }
  
      public function analytics()
      {
          return view('admin.pages.admin.configuracoes.analytics.index');
      }
  
      public function update($id, Factory $cache, Setting $setting)
      {
          $this-&gt;repository-&gt;findByName($setting);
  
          $cache-&gt;forget('settings');
  
          return redirect('admin');
      }
  }
  </code></pre>
  
  <p>My SettingRepository:</p>
  
  <pre><code>class SettingRepository
  {
      private $model;
  
      public function __construct(Setting $model)
      {
          $this-&gt;model = $model;
      }
  
      public function findByName($name){
          return $this-&gt;model-&gt;where('name', $name)-&gt;update();
      }
  }
  </code></pre>
  
  <p>My blade form:</p>
  
  <pre><code>{!! Form::model(config('settings'), ['class' =&gt; 's-form', 'route' =&gt; ['setting.update']]) !!}
  {{ method_field('PUT') }}
  &lt;div class="s-form-item text"&gt;
      &lt;div class="item-title required"&gt;Título do artigo&lt;/div&gt;
      {!! Form::text('title', null, ['placeholder' =&gt; 'Nome do site']) !!}
      @if($errors-&gt;has('title'))
          &lt;div class="item-desc"&gt;{{ $errors-&gt;first('title') }}&lt;/div&gt;
      @endif
  &lt;/div&gt;
  &lt;div class="s-form-item s-btn-group s-btns-right"&gt;
      &lt;a href="{{ url('admin') }}" class="s-btn cancel"&gt;Voltar&lt;/a&gt;
      &lt;input class="s-btn" type="submit" value="Atualizar"&gt;
  &lt;/div&gt;
  {!! Form::close() !!}
  </code></pre>
  
  <p>But things does not work. How can I update the values into the table?</p>