akubiczek /
applicake-backend
| 1 | <?php |
||
| 2 | |||
| 3 | namespace App\Models; |
||
| 4 | |||
| 5 | use Illuminate\Database\Eloquent\SoftDeletes; |
||
| 6 | use Illuminate\Foundation\Auth\User as Authenticatable; |
||
| 7 | use Illuminate\Notifications\Notifiable; |
||
| 8 | use Laravel\Passport\HasApiTokens; |
||
| 9 | use Spatie\Permission\Traits\HasRoles; |
||
| 10 | |||
| 11 | class User extends Authenticatable |
||
| 12 | { |
||
| 13 | use HasRoles; |
||
|
0 ignored issues
–
show
introduced
by
Loading history...
|
|||
| 14 | use HasApiTokens; |
||
| 15 | use Notifiable; |
||
|
0 ignored issues
–
show
|
|||
| 16 | use SoftDeletes; |
||
| 17 | |||
| 18 | protected $connection = 'tenant'; |
||
| 19 | |||
| 20 | /** |
||
| 21 | * The attributes that are mass assignable. |
||
| 22 | * |
||
| 23 | * @var array |
||
| 24 | */ |
||
| 25 | protected $fillable = [ |
||
| 26 | 'name', 'email', 'password', |
||
| 27 | ]; |
||
| 28 | |||
| 29 | /** |
||
| 30 | * The attributes that should be hidden for arrays. |
||
| 31 | * |
||
| 32 | * @var array |
||
| 33 | */ |
||
| 34 | protected $hidden = [ |
||
| 35 | 'password', 'remember_token', |
||
| 36 | ]; |
||
| 37 | |||
| 38 | /** |
||
| 39 | * The attributes that should be cast to native types. |
||
| 40 | * |
||
| 41 | * @var array |
||
| 42 | */ |
||
| 43 | protected $casts = [ |
||
| 44 | 'email_verified_at' => 'datetime', |
||
| 45 | ]; |
||
| 46 | |||
| 47 | /** |
||
| 48 | * Find the user instance for the given username. |
||
| 49 | * |
||
| 50 | * @param string $username |
||
| 51 | * |
||
| 52 | * @return User |
||
| 53 | */ |
||
| 54 | public function findForPassport($username) |
||
| 55 | { |
||
| 56 | return $this->where('email', $username)->where('pending_invitation', 0)->first(); |
||
| 57 | } |
||
| 58 | |||
| 59 | /** |
||
| 60 | * Used to determine access rights if a user has limited role. |
||
| 61 | * |
||
| 62 | * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany |
||
| 63 | */ |
||
| 64 | public function grantedRecruitments() |
||
| 65 | { |
||
| 66 | return $this->belongsToMany(Recruitment::class)->withTimestamps(); |
||
| 67 | } |
||
| 68 | } |
||
| 69 |