80 lines
1.9 KiB
PHP
80 lines
1.9 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
// use Illuminate\Contracts\users\MustVerifyEmail;
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
|
use Illuminate\Foundation\Auth\User as Authenticatable;
|
|
use Illuminate\Notifications\Notifiable;
|
|
use Laravel\Sanctum\HasApiTokens;
|
|
use LdapRecord\Laravel\Auth\LdapAuthenticatable;
|
|
use LdapRecord\Laravel\Auth\AuthenticatesWithLdap;
|
|
|
|
class User extends Authenticatable implements LdapAuthenticatable
|
|
{
|
|
use HasApiTokens, HasFactory, Notifiable, SoftDeletes, AuthenticatesWithLdap;
|
|
|
|
/**
|
|
* The attributes that are mass assignable.
|
|
*
|
|
* @var array<int, string>
|
|
*/
|
|
protected $fillable = [
|
|
'name',
|
|
'username',
|
|
'password',
|
|
'guid',
|
|
'domain'
|
|
];
|
|
|
|
/**
|
|
* The attributes that should be hidden for serialization.
|
|
*
|
|
* @var array<int, string>
|
|
*/
|
|
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');
|
|
}
|
|
|
|
}
|