title: Laravel hasMany detach
body: <p>I am having an issue with Eloquent regarding removing child model:
  When this is executed in <code>process2()</code> I still have the deleted model which is not ok.</p>
  
  <h2>Model</h2>
  
  <pre><code>    namespace App\Models;
  
      use Illuminate\Database\Eloquent\Model;
  
      class Model1 extends Model
      {
          public function seasons() {
              return $this-&gt;hasMany('App\Models\Seasons', 'series_id', 'id');
          }
      }
  </code></pre>
  
  <h2>Service</h2>
  
  <pre><code>class Process {
      public function process1($model1Instance) {
  
          for($model1Instance-&gt;seasons() as $season) {
              if(//whatever//) {
                  $season-&gt;delete();
              }
          }
      }
      public function process2($model1Instance) {
          for($model1Instance-&gt;seasons() as $season) {
              //At this point I still have the deleted instance
          }
      }
  }
  </code></pre>
  
  <h2>Usage</h2>
  
  <pre><code>$proc = new Process();
  ......
  $proc-&gt;process1($model1Instance);
  $proc-&gt;process2($model1Instance);
  </code></pre>
  
  <p>When <code>process1()</code> removes a model from the parent, how can I have it removed in <code>process2()</code>?</p>
  
  <h2>Tried/Will try:</h2>
  
  <p>1.Method:
      $model1Instance->seasons()->detach($season);
  but got: <code>Call to undefined method Illuminate\Database\Query\Builder::detach()</code></p>
  
  <p>2.Another class
      I could make another simple class to store these but I do not think it is okay, although I could then set filtered seasons but still have to use Model1 instance:</p>
  
  <pre><code>class Model1Copy {
      private $seasons;
      public function __construct($seasons) {
          $this-&gt;seasons = $seasons;
      }
  }
  </code></pre>
  
  <ol start="3">
  <li><p>Fatal when tried:</p>
  
  <p>public function process1($model1Instance) {</p>
  
  <pre><code>for($model1Instance-&gt;seasons() as $season) {
      if(//whatever//) {
          $season-&gt;delete();
      } else {
      $childs[]=$season;
      }
  }
  $model1Instance-&gt;seasons = $childs
  </code></pre>
  
  <p>}</p></li>
  <li><p>Would be to make my own repositories to skip the ORM`s behavior, but it is frustrating because I have to rewrite all queries just to remove an instance...</p></li>
  </ol>