title: Laravel can I use pivot table as a model
body: <p>I have three tables <strong>staff</strong>, <strong>customer</strong>, <strong>service</strong>. </p>
  
  <p>I have created pivot for customer and service as <strong>customer_service</strong>(has extra fields). </p>
  
  <p>Now I want to link the staff to customer_service. So i tried to use customer_service as a <strong>model</strong> '<strong>Custserv</strong>' and tried to relate with <strong>staff</strong>. It didnt workout.</p>
  
  <p>Because I don't want staff linking directly to customer and service</p>
  
  <p>I had this following relationship working</p>
  
  <pre><code>/*Model - Service*/
  public function customer(){
      return $this-&gt;belongsToMany('customer')-&gt;withPivot(
          'start_date',
          'stop_date',
          'rem_date',
          'due_date',
          'status'
          );
  }
  
  /*Model - customer*/
  public function services(){
      return $this-&gt;belongsToMany('Service')-&gt;withPivot(
          'start_date',
          'stop_date',
          'rem_date',
          'due_date',
          'status'
          );
  }
  
  ////These following relations didnt workout
  /*Model - custserv*/ //uses the pivot table customer_service//
  public function staff(){
      return $this-&gt;belongsToMany('Staff');
  }
  
  /*Model - Staff*/
  public function custservs(){
      return $this-&gt;belongsToMany('Custserv');
  }
  
  /*schema for pivot table 'staff' and 'Custserv' */
  Schema::create('customer_service_user', function(Blueprint $table)
      {
          $table-&gt;increments('id');
          $table-&gt;integer('customer_service_id')-&gt;unsigned()-&gt;index();
          $table-&gt;foreign('customer_service_id')-&gt;references('id')-&gt;on('customer_service')-&gt;onDelete('cascade');
          $table-&gt;integer('staff_id')-&gt;unsigned()-&gt;index();
          $table-&gt;foreign('staff_id')-&gt;references('id')-&gt;on('staff')-&gt;onDelete('cascade');
          $table-&gt;timestamps();
      });
  </code></pre>
  
  <p>Then I tried ...</p>
  
  <pre><code>$staff = User::find(1)-&gt;custservs;
  return $staff;
  </code></pre>
  
  <p>It gave error</p>
  
  <pre><code>SQLSTATE[42S02]: Base table or view not found: 1146 Table 'auditCrm_db.custserv_user' doesn't exist (SQL: select `customer_service`.*, `custserv_user`.`user_id` as `pivot_user_id`, `custserv_user`.`custserv_id` as `pivot_custserv_id` from `customer_service` inner join `custserv_user` on `customer_service`.`id` = `custserv_user`.`custserv_id` where `custserv_user`.`user_id` = 1) 
  </code></pre>
  
  <p>If my relationshiop is correct how to get and set values between Staff and Custserv?</p>