2026-05-07 23:31:33 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace App\Models;
|
|
|
|
|
|
|
|
|
|
// use Illuminate\Contracts\Auth\MustVerifyEmail;
|
|
|
|
|
use Database\Factories\UserFactory;
|
|
|
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
|
|
|
use Illuminate\Foundation\Auth\User as Authenticatable;
|
|
|
|
|
use Illuminate\Notifications\Notifiable;
|
|
|
|
|
use Spatie\Permission\Traits\HasRoles;
|
|
|
|
|
|
|
|
|
|
class User extends Authenticatable
|
|
|
|
|
{
|
|
|
|
|
/** @use HasFactory<UserFactory> */
|
|
|
|
|
use HasFactory, Notifiable, HasRoles;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* The attributes that are mass assignable.
|
|
|
|
|
*
|
|
|
|
|
* @var list<string>
|
|
|
|
|
*/
|
|
|
|
|
protected $fillable = [
|
2026-06-16 18:25:36 +02:00
|
|
|
'name',
|
|
|
|
|
'email',
|
|
|
|
|
'password', // Intentionally kept: required for registration factory and seeding.
|
|
|
|
|
// Sensitive — never pass unvalidated user input directly.
|
|
|
|
|
// email_verified_at and remember_token are intentionally excluded.
|
2026-05-07 23:31:33 +02:00
|
|
|
];
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* The attributes that should be hidden for serialization.
|
|
|
|
|
*
|
|
|
|
|
* @var list<string>
|
|
|
|
|
*/
|
|
|
|
|
protected $hidden = [
|
|
|
|
|
'password',
|
|
|
|
|
'remember_token',
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get the attributes that should be cast.
|
|
|
|
|
*
|
|
|
|
|
* @return array<string, string>
|
|
|
|
|
*/
|
|
|
|
|
protected function casts(): array
|
|
|
|
|
{
|
|
|
|
|
return [
|
|
|
|
|
'email_verified_at' => 'datetime',
|
2026-06-16 18:25:36 +02:00
|
|
|
'password' => 'hashed',
|
2026-05-07 23:31:33 +02:00
|
|
|
];
|
|
|
|
|
}
|
2026-06-17 09:32:07 +02:00
|
|
|
public function company()
|
|
|
|
|
{
|
|
|
|
|
return $this->belongsTo(Company::class);
|
|
|
|
|
}
|
|
|
|
|
|
2026-05-07 23:31:33 +02:00
|
|
|
// Many-to-many with projects
|
|
|
|
|
public function projects()
|
|
|
|
|
{
|
|
|
|
|
return $this->belongsToMany(Project::class)->withPivot('role_in_project')->withTimestamps();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Progress updates made
|
|
|
|
|
public function progressUpdates()
|
|
|
|
|
{
|
|
|
|
|
return $this->hasMany(ProgressUpdate::class);
|
|
|
|
|
}
|
|
|
|
|
}
|