title: Laravel delete related records
body: <p>I've got 1 company. That company hasMany departments. When I want to softdelete company the departments should be softdeleted aswell. Right now I'm doing that like this:</p>
  
  <p>Company.php</p>
  
  <pre><code>protected static function boot()                         
  {                                                        
      parent::boot();                                      
      static::deleting(function($company) {                
          foreach($company-&gt;department as $department)     
          {                                                
              $department-&gt;delete();                       
          }                                                
      });                                                  
  }   
  </code></pre>
  
  <p>But for some reason only the first department is beeing softdeleted while the company has for example 17 departments.</p>
  
  <p>What am I doing wrong??? I'm looking for hours right now still no solution! </p>
  
  <p>--EDIT--</p>
  
  <p>A department hasMany Employees. </p>
  
  <pre><code>protected static function boot()
      {
          parent::boot();
          static::deleting(function($department) {
              Employee::where('DepartmentId','=',$department-&gt;DepartmentId)-&gt;delete();
          });
      }       
  </code></pre>