Files
Plataforma-de-Tutoriais/plataforma-tutorias/app/Models/User.php
2026-06-16 12:25:58 +01:00

57 lines
1.1 KiB
PHP

<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
use Tymon\JWTAuth\Contracts\JWTSubject;
use App\Models\Sector;
class User extends Authenticatable implements JWTSubject
{
use HasFactory, Notifiable;
protected $fillable = [
'name',
'email',
'password',
'role_id',
'sector_id',
'created_at',
];
protected $hidden = [
'password',
'remember_token',
];
protected $casts = [
'email_verified_at' => 'datetime',
];
public function getJWTIdentifier()
{
return $this->getKey();
}
public function getJWTCustomClaims()
{
return [];
}
public function role()
{
return $this->belongsTo(Role::class);
}
public function workshops()
{
return $this->belongsToMany(Workshop::class, 'user_workshop')->withTimestamps();
}
public function sector()
{
return $this->belongsTo(Sector::class, 'sector_id', 'id');
}
}