title: Laravel: Controller function to delete the data
body: <p>I will explain first the tables and how code works</p>
  
  <p><strong>Tables</strong></p>
  
  <p>I have: </p>
  
  <ul>
  <li>projects with fields: id, slug, order, public, pathheader and pathhome.</li>
  <li>project_translations with fields: id, locale, project_id, title and caption.</li>
  <li>clients with fields: id, name, slug and priority.</li>
  <li>client_project with fields: id, client_id and project_id</li>
  </ul>
  
  <p><strong>How the code works</strong></p>
  
  <p>When I create a project, I create two project translation too (one for each locale, ex: 'es', 'en'). and then I select a client and this makes the relation client_project.</p>
  
  <p>When I delete the project, I delete at the same time the project_translations which have the same project_id and the client_project row where project_id is the same.</p>
  
  <p><strong>What I want</strong></p>
  
  <p>When I delete the client, delete the row which field client_id have the same value (this is working) and then, delete the projects and projects_translations of the projects which have relation with the client i deleted.</p>
  
  <p><strong>How my function looks for the moment</strong></p>
  
  <pre><code>public function destroyClient($id) //Destruir cliente y todo lo relacionado de la bbdd
      {
          $cliente = Client::find($id); 
          $cliente-&gt;delete(); //delete the client
          DB::table('client_project')-&gt;where('client_id',$id)-&gt;delete(); //delete the client_project relations which field client_id is the same that the client i just deleted.
  
          return redirect()-&gt;route('admin.clients');
      }
  </code></pre>