title: Laravel API Architecture - best practices
body: <p>I'm implementing an API that can create clients and create contacts. Contacts may be associated with a client.</p>
  
  <p>I have my ClientController.php with all the CRUD methods.</p>
  
  <p>I also have a ContactController.php with all the CRUD methods.</p>
  
  <p>I want to allow a contact to be created and assigned to a client all in the one API call.</p>
  
  <p>I was thinking the best way would be add a function to my ClientController and call it via the API: <strong>/api/client/6/addContact</strong></p>
  
  <pre><code>public function addContact($clientId, Request $request) {
     $contact = new Contact($request-&gt;all())-&gt;save();
  
     $client = Client::find($clientId)-&gt;attach($contact-&gt;id);
  
     return response()-&gt;json(null, 200);
  
  }
  </code></pre>
  
  <p>But my issue is that the method to add a contact (and validate it) is in the ContactController.php, so i'm doubling up on the code. How can I use the ContactController@store method from the ClientController@addContact ?</p>
  
  <p>Is there a common API architecture for these types of issues?</p>
  
  <p>Thanks!</p>