step 1, 2 and 3 of the implementation plan
This commit is contained in:
84
app/Models/Session.php
Normal file
84
app/Models/Session.php
Normal file
@@ -0,0 +1,84 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
|
||||
final class Session extends Model
|
||||
{
|
||||
protected $table = 'questionnaire_sessions';
|
||||
|
||||
/**
|
||||
* Fillable attributes for mass assignment.
|
||||
*/
|
||||
protected $fillable = [
|
||||
'user_id',
|
||||
'category_id',
|
||||
'screening_id',
|
||||
'status',
|
||||
'score',
|
||||
'result',
|
||||
'basic_info',
|
||||
'additional_comments',
|
||||
'completed_at',
|
||||
];
|
||||
|
||||
/**
|
||||
* Cast attributes to specific types.
|
||||
*/
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'user_id' => 'integer',
|
||||
'category_id' => 'integer',
|
||||
'screening_id' => 'integer',
|
||||
'score' => 'integer',
|
||||
'basic_info' => 'array',
|
||||
'completed_at' => 'datetime',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the user that owns this session.
|
||||
*/
|
||||
public function user(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the category for this session.
|
||||
*/
|
||||
public function category(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Category::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the screening that preceded this session.
|
||||
*/
|
||||
public function screening(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Screening::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all answers for this session.
|
||||
*/
|
||||
public function answers(): HasMany
|
||||
{
|
||||
return $this->hasMany(Answer::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all logs for this session.
|
||||
*/
|
||||
public function logs(): HasMany
|
||||
{
|
||||
return $this->hasMany(Log::class);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user