*/ protected $fillable = [ 'name', 'username', 'password', 'guid', 'domain' ]; /** * The attributes that should be hidden for serialization. * * @var array */ protected $hidden = [ 'password', 'remember_token', ]; /** * Gets the Loaner Type that the users belongs to * @return BelongsTo */ public function loanerType(): BelongsTo { return $this->belongsTo(LoanerType::class); } /** * Gets the roles that the users belongs to * @return BelongsTo */ public function role(): BelongsTo { return $this->belongsTo(Role::class); } public function loans() { return $this->hasMany(Loan::class,'user_id') ->where('loan_type_id','=',LoanType::where('name','=','Loan')->first()->id) ; } public function reservations() { return $this->hasMany(Loan::class,'user_id') ->where('loan_type_id','!=',LoanType::where('name','=','Loan')->first()->id) ; } public function notes() { return $this->hasMany(Note::class,'user_id'); } }