title: Laravel hasMany relationship detach all
body: <p>Is there a simple solution to detach (without deleting) all related models through a hasMany Relation on a model?</p>
  
  <p>For example, I have two tables:</p>
  
  <ul>
  <li><p>College (id, name)</p></li>
  <li><p>Student (id, name, college_id(nullable) )</p></li>
  </ul>
  
  <p>In the College model I define this relationship:</p>
  
  <pre><code>class College extends Model
  {
      public function students()
      {
          return $this-&gt;hasMany('App\Student','college_id','id');
      }
  }
  </code></pre>
  
  <p>What is the best way to detach all current College students from the College (i.e, get all the students of the college and set their college_id to <code>null</code>)?</p>
  
  <p>Is there an easy way to detach all students from the College model using eloquent?</p>
  
  <p>Something like</p>
  
  <pre><code>class College extends Model
  {
      ...
      public function detachAllStudents()
      {
          ...
      }
  }
  </code></pre>
  
  <p>P.S. already have read this question <a href="https://stackoverflow.com/questions/32662569/laravel-hasmany-detach">Laravel hasMany detach</a>, but get errors when I try to apply it to my application</p>