title: Illuminate \ Database \ Eloquent \ ModelNotFoundException - No query results for model In laravel
body: <p>I have the following data model</p>
  
  <p><img src="https://i.stack.imgur.com/weBvH.png" alt="enter image description here"></p>
  
  <p>I am trying to get a have a <code>Servicio</code> given a <code>Auth_Token</code> of a <code>Tecnico</code> and <code>id</code> of a <code>Servicio</code>, but I get the following error appears</p>
  
  <p><img src="https://i.stack.imgur.com/wZIxf.png" alt="enter image description here"></p>
  
  <p>This is my code</p>
  
  <p><strong>Route</strong></p>
  
  <pre><code>Route::post('servicio/download/{id}', array('uses' =&gt; 'ServicioController@pdf'));
  </code></pre>
  
  <p><strong>Servicio model</strong></p>
  
  <pre><code>class Servicio extends Eloquent{
  protected $table  = 'Servicio';
  protected $fillable = array(
                              'RutaFoto1',
                              'RutaFoto2',
                              'RutaFoto3',
                              'RutaFoto4',
                              'FechaTermino',
                              'Latitud',
                              'Longitud'
                              );
  protected $primaryKey = 'idServicio';
  
  public function materialUsado(){
      return $this-&gt;hasMany('Material_Usado', 'idMaterial_Usado');
  }
  
  public function tecnicos(){
      return $this-&gt;belongsToMany('Tecnico', 'Servicio_Tecnico', 'Servicio_idServicio', 'Tecnico_idTecnico');
  }
      }
  </code></pre>
  
  <p><strong>Tecnico Model</strong></p>
  
  <pre><code>class Tecnico extends Eloquent{
  protected $table = 'Tecnico';
  protected $fillable = array('Auth_Token');
  protected $primaryKey = 'idTecnico';
  
  public function servicios(){
      return $this-&gt;belongsToMany('Servicio', 'Servicio_Tecnico', 'Tecnico_idTecnico', 'Servicio_idServicio');
  }
   }
  </code></pre>
  
  <p><strong>ServicioController</strong></p>
  
  <pre><code>class ServicioController extends BaseController{
  
  public function pdf($id){
      $auth = Input::get('Auth_Token');
      $tecnico = Tecnico::with('servicios')-&gt;where('Auth_Token',$auth)-&gt;firstOrFail();
          if($tecnico != ''){
              $servicios = $tecnico-&gt;servicios;
              $servicio = $servicio-&gt;where('idServicio', $id)-&gt;first();
              if($servicio != null){
                  $array = array(
                              'idServicio' =&gt; $servicio-&gt;idServicio,
                              'RutaPDF' =&gt; base64_encode($servicio-&gt;RutaPDF),
                                  );
                  $response = Response::json($$array);
                  return $response;
              }else{
                  $array = array('Error' =&gt; '', 'Code' =&gt; '');
                  return Response::json($array);
              }
          }else{
              $array = array('Error' =&gt; 'NotAuthorizedError', 'Code' =&gt; '403', 'Message' =&gt; 'Tecnico inexistente');
              $response = Response::json($array);
              return $response;
          }
  
  }
      } 
  </code></pre>
  
  <p>how can I fix it?</p>