title: Using scope to filter data
body: <p>I am trying to do a search, I have verified that the data is received but not to make it show the filter.</p>
  
  <p><strong>Sending the data</strong></p>
  
  <pre><code>&lt;div class="panel-body"&gt;
  
      {!! Form::open (['route' =&gt; 'report.index', 'method'=&gt;'GET', 'class' =&gt; 'navbar-form navbar-left pull-right']) !!}
          &lt;div class="form-group"&gt;
              &lt;input type="text" name= "name" class="form-control" placeholder="Buscar por Servicio"&gt;
          &lt;/div&gt;
          &lt;button  type="submit" class="btn btn-default"&gt;Buscar&lt;/button&gt;
  </code></pre>
  
  <p><strong>At the controller:</strong></p>
  
  <pre><code>class ControllerReport extends Controller
  {
      public function index(Request $request)
      {    
          $servicio = mivista::name($request-&gt;get('name'));
  
          return view('report.buscar_pagos', compact('servicio'));
      }
  }
  </code></pre>
  
  <p><strong>and in the model:</strong></p>
  
  <pre><code>&lt;?php
  
  namespace App;
  
  use Illuminate\Database\Eloquent\Model;
  use Illuminate\Database\Eloquent\Scope;
  
  use Illuminate\Database\Eloquent\Builder;
  
  class mivista extends Model
  {
      protected $table = 'mivista';
  
      public function scopeName($query,$name)
      {
          if ( ! is_null($name)) {
              return $query-&gt;where('name', 'like', '%'.$name.'%');
          }
      }
  }
  </code></pre>
  
  <p>I clarify that leaving <code>$service = mivista::all();</code> In the controller shows me all the data, but I can not make the search work with the name parameter.
  Waiting for your help, thank you in advance</p>