adds roles
This commit is contained in:
@@ -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
23
app/Models/Role.php
Normal 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);
|
||||
}
|
||||
}
|
||||
@@ -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',
|
||||
];
|
||||
}
|
||||
|
||||
@@ -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.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user