title: Make eloquent model for subtype
body: <p>I'm creating a school platform where students, teachers,... can login using their credentials. To reduce duplicate data I did not make a separate table called students, instead I keep all the data in the users table.</p>
  
  <p>To know if a user is a student I a have a table that is called enrolments, in this table a <code>user_id</code> , <code>schoolyear_id</code> and <code>class_id</code> is stored. </p>
  
  <p>I already made a student model that refers to the users table, but how can I ensure that this model only passes students?</p>
  
  <p>EER:
  <a href="https://i.stack.imgur.com/bhJBd.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/bhJBd.png" alt="EER overview"></a></p>
  
  <p>Student.php:</p>
  
  <pre><code>&lt;?php
  
  namespace App;
  
  class Student extends User
  {
      protected $table= 'users';
  
      public function enrollments(){
          return $this-&gt;belongsToMany(Enrollment::class);
      }
  }
  </code></pre>
  
  <p>User.php:</p>
  
  <pre><code>&lt;?php
  
  namespace App;
  
  use Illuminate\Notifications\Notifiable;
  use Illuminate\Foundation\Auth\User as Authenticatable;
  use Spatie\Permission\Traits\HasRoles;
  use Illuminate\Support\Facades\Auth;
  
  class User extends Authenticatable
  {
      use Notifiable;
      use HasRoles;
  
      /**
       * The attributes that are mass assignable.
       *
       * @var array
       */
      protected $fillable = [
          'first_name','last_name', 'password'
      ];
  
      /**
       * The attributes that should be hidden for arrays.
       *
       * @var array
       */
      protected $hidden = [
          'password', 'remember_token',
      ];
  
      public function profiles(){
          return $this-&gt;hasOne(Profile::class);
      }
  
  }
  </code></pre>
  
  <p>What I want to achieve is that when I call the <code>Student::all();</code> function I get all the users who are enrolled in the school,hence students.</p>