MIF_E31231594/app/Models/User.php

52 lines
1.4 KiB
PHP

<?php
namespace App\Models;
// use Illuminate\Contracts\Auth\MustVerifyEmail;
use Illuminate\Database\Eloquent\Attributes\Fillable;
use Illuminate\Database\Eloquent\Attributes\Hidden;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
#[Fillable(['name', 'email', 'password', 'role', 'profile_photo_path'])]
#[Hidden(['password', 'remember_token'])]
class User extends Authenticatable
{
use HasFactory, Notifiable;
/**
* Get the attributes that should be cast.
*
* @return array<string, string>
*/
protected function casts(): array
{
return [
'email_verified_at' => 'datetime',
'password' => 'hashed',
];
}
public function organisasiSebagaiPembina(): BelongsToMany
{
return $this->belongsToMany(Organisasi::class, 'organisasi_user')
->wherePivot('role', 'pembina')
->withTimestamps();
}
public function organisasiSebagaiKetua(): BelongsToMany
{
return $this->belongsToMany(Organisasi::class, 'organisasi_user')
->wherePivot('role', 'ketua')
->withTimestamps();
}
public function sessions(): HasMany
{
return $this->hasMany(Session::class, 'user_id');
}
}