title: Create a New Model (Polimorphic) based on some of the fields of another just created Model - Laravel 8
body: <p>I'd like to make an enhancement of the code, that actually feels a mess.</p>
  <p>When I create a User that has an 'email' field. I also need to create an Email model (Polymorphic) based on that same data.</p>
  <p>Actually the UserController's &quot;store&quot; method looks a little big. So, is there another way of hooking the creation event, and then create the Email. Here is how I'm doing now:</p>
  <pre><code>$user = User::make($request-&gt;safe()-&gt;except('active', 'is_contact', 'groups', 'password'));
  $user-&gt;password = Hash::make($request-&gt;password);
  $user-&gt;active = (!empty($request-&gt;active)) ? 1 : 0;
  $user-&gt;is_contact = (!empty($request-&gt;is_contact)) ? 1 : 0;
  $user-&gt;save();
  
  $this-&gt;saveEmail($user);
  </code></pre>
  <p>And the saveEmail:</p>
  <pre><code>private function saveEmail($user)
  {
      $email = new Email;
      $email-&gt;fill([
          'email' =&gt; $user-&gt;email,
          'email_type' =&gt; 'primary',
          'main' =&gt; 1,
      ]);
  
      $user-&gt;emails()-&gt;save($email);
  }
  </code></pre>
  <p>So, is there another way of doing this outside of the controller?
  Thanks anyway. Hernán.</p>