title: Laravel updating polymorphic relation
body: <p>First of all, if there is a better way than using a polymorphic relation for this then please let me know. I have an appointments table that can have either a contact id or a relation id, depending on what the user selects when creating a new appointment. For this I am using a polymorphic relation, instead of having two seperate <code>contact_id</code> and <code>relation_id</code> columns.</p>
  
  <p>Also, if there is a better way of doing the below (which I am currently doing in both my store and update methods) then please elaborate me.</p>
  
  <pre><code>    if ($request-&gt;has('contact_id'))
      {
          Contact::find($request['contact_id'])-&gt;appointments()-&gt;save($appointment);
      }
  
      if ($request-&gt;has('relation_id'))
      {
          Relation::find($request['relation_id'])-&gt;appointments()-&gt;save($appointment);
      }
  </code></pre>
  
  <p>The above basically checks if either a contact or relation was selected from one of the dropdowns, and if so, it should add that polymorphic relation to the newly inserted appointment.</p>
  
  <p>But what I am doing in my update method, before I check if a contact_id or relation_id has been specified, is the following:</p>
  
  <pre><code>Appointment::where('id', $appointment-&gt;id)-&gt;update(['relationship_id' =&gt; '0', 'relationship_type' =&gt; '']);
  </code></pre>
  
  <p>So, I first empty the polymorphic relation, and then check for updates, because a contact or relation is optional. So when someone updates his/her appointment, and removes a at first specified contact or relation, it should be cleared from the database. There has gotta be a better way of going about this, and I know that what I am doing is not the way to go. But I am new to polymorphic relations and just trying to learn more about them. Any info will be appreciated :)</p>