title: Laravel: difference between using a Trait or extending a model
body: <p>We're working on a Laravel application with a scheduling module. The module has three types of classes that can be put in an agenda: Task, Event and Department. We've therefore come up with the following class diagram:
  <a href="https://i.stack.imgur.com/G3QDo.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/G3QDo.png" alt="Class Diagram"></a>
  Now, our question: if we were to realise this diagram, should we use a Trait or should we extend a Plannable model.</p>
  
  <p>Plannable model:</p>
  
  <pre><code>&lt;?php
  
  namespace App;
  
  use Illuminate\Database\Eloquent\Model;
  
  class Plannable extends Model
  {
      // Code
  }
  </code></pre>
  
  <p>Task model:</p>
  
  <pre><code>&lt;?php
  
  namespace App;
  
  use App\Plannable;
  
  class Task extends Plannable
  {
      // Code
  }
  </code></pre>
  
  <p>Or should we use this as a trait:</p>
  
  <p>Plannable trait:</p>
  
  <pre><code>&lt;?php
  
  namespace App\Traits;
  
  trait Plannable
  {
      // Code
  }
  </code></pre>
  
  <p>Task model:</p>
  
  <pre><code>&lt;?php
  
  namespace App;
  
  use App\Plannable;
  use Illuminate\Database\Eloquent\Model;
  
  class Task extends Model
  {
      use Plannable;
      // Code
  }
  </code></pre>