title: Laravel eloquent conditional relationship
body: <p>I am trying to set up a conditional relationship in eloquent model based on the value of table column, but it does not works.</p>
  
  <p>This is the code that I am using:</p>
  
  <pre><code> //RELATIONS
  public function task_schedule()
  {
      if ($this-&gt;task_schedule_id === 0) {
          return $this-&gt;belongsTo('TaskSchedule', 'hold_task_schedule_id', 'id');
      } else {
          return $this-&gt;belongsTo('TaskSchedule');
      }
  
  }
  </code></pre>
  
  <p>Basically I want to use different column to get my child model defined in belongs to relationship. </p>
  
  <p>scopeProfile($query) would not work for me because I dont want to retrieve the child in every single query and also <strong>I am using Task->with('task_schedule')</strong> in a lot parts of code.</p>