adds roles

This commit is contained in:
2026-02-16 11:19:06 +01:00
parent ebaeb1722d
commit 4dc64c22cb
29 changed files with 495 additions and 89 deletions

View File

@@ -7,6 +7,7 @@
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\HasMany;
final class Question extends Model
{
@@ -48,4 +49,12 @@ public function questionGroup(): BelongsTo
{
return $this->belongsTo(QuestionGroup::class);
}
/**
* Get all answers for this question.
*/
public function answers(): HasMany
{
return $this->hasMany(Answer::class);
}
}

23
app/Models/Role.php Normal file
View File

@@ -0,0 +1,23 @@
<?php
declare(strict_types=1);
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\HasMany;
final class Role extends Model
{
protected $fillable = [
'name',
];
/**
* Get all users with this role.
*/
public function users(): HasMany
{
return $this->hasMany(User::class);
}
}

View File

@@ -25,7 +25,6 @@ final class Session extends Model
'status',
'score',
'result',
'basic_info',
'additional_comments',
'completed_at',
];
@@ -40,7 +39,6 @@ protected function casts(): array
'category_id' => 'integer',
'screening_id' => 'integer',
'score' => 'integer',
'basic_info' => 'array',
'completed_at' => 'datetime',
];
}

View File

@@ -5,6 +5,7 @@
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
@@ -23,6 +24,12 @@ final class User extends Authenticatable
'name',
'email',
'password',
'azure_id',
'photo',
'job_title',
'department',
'phone',
'role_id',
];
/**
@@ -33,6 +40,7 @@ final class User extends Authenticatable
protected $hidden = [
'password',
'remember_token',
'azure_id',
];
/**
@@ -45,9 +53,18 @@ protected function casts(): array
return [
'email_verified_at' => 'datetime',
'password' => 'hashed',
'role_id' => 'integer',
];
}
/**
* Get the role assigned to this user.
*/
public function role(): BelongsTo
{
return $this->belongsTo(Role::class);
}
/**
* Get all sessions for this user.
*/