'datetime', ]; public function passwordSecurity() { return $this->hasOne('App\Models\Core\Auth\PasswordSecurity'); } public function teams() { return $this->hasManyThrough(Team::class, TeamUser::class, 'user_id', 'id', 'id', 'team_id'); } public function scopeByTeam($query, $id) { return $query->whereHas('teams', function ($query) use ($id) { $query->where('id', $id); }); } public function scopeByUniqueTeam($query) { return $query->has('teams', '=', 1); } public function scopeActive($query) { return $query->where('active', 1); } }