TIF_E41212002/app/Models/User.php

74 lines
1.6 KiB
PHP

<?php
namespace App\Models;
// use Illuminate\Contracts\Auth\MustVerifyEmail;
use Illuminate\Database\Eloquent\Concerns\HasUuids;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
use Laravel\Sanctum\HasApiTokens;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\Relations\HasOne;
class User extends Authenticatable
{
use HasApiTokens, HasFactory, Notifiable, HasUuids;
protected $table = "users";
public $incrementing = false;
protected $keyType = "string";
/**
* The attributes that are mass assignable.
*
* @var array<int, string>
*/
protected $fillable = [
'name',
'email',
'password',
'status',
'role_id',
];
/**
* The attributes that should be hidden for serialization.
*
* @var array<int, string>
*/
protected $hidden = [
'password',
'remember_token',
];
/**
* The attributes that should be cast.
*
* @var array<string, string>
*/
protected $casts = [
'email_verified_at' => 'datetime',
'password' => 'hashed',
];
public function role(): BelongsTo
{
return $this->belongsTo(Role::class);
}
public function pembelajarans()
{
return $this->belongsToMany(Pembelajaran::class, 'pembelajaran_user');
}
public function student(): HasOne
{
return $this->hasOne(\App\Models\Student::class, 'user_id');
}
}