35 lines
705 B
PHP
35 lines
705 B
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\HasOne;
|
|
|
|
class PrelimScoreSheet extends Model
|
|
{
|
|
protected $fillable = [
|
|
'user_id',
|
|
'entry_id',
|
|
'subscores',
|
|
'total',
|
|
];
|
|
|
|
protected $casts = ['subscores' => 'json'];
|
|
|
|
public function user(): HasOne
|
|
{
|
|
return $this->hasOne(User::class);
|
|
}
|
|
|
|
public function entry(): HasOne
|
|
{
|
|
return $this->hasOne(Entry::class);
|
|
}
|
|
|
|
public function getSubscore($id)
|
|
{
|
|
return $this->subscores[$id]['score'] ?? false;
|
|
// this function is used at resources/views/tabulation/entry_score_sheet.blade.php
|
|
}
|
|
}
|