belongsTo(School::class); } public function users(): HasManyThrough { return $this->hasManyThrough( User::class, // The target model we want to access School::class, // The intermediate model through which we access the target model 'id', // The foreign key on the intermediate model 'school_id', // The foreign key on the target model 'school_id', // The local key 'id' // The local key on the intermediate model ); } public function directors(): HasManyThrough { return $this->users(); } public function entries(): HasMany { return $this->hasMany(Entry::class); } public function full_name(bool $last_name_first = false): string { if ($last_name_first) { return $this->last_name.', '.$this->first_name; } return $this->first_name.' '.$this->last_name; } }