Files
sam-manage/app/Models/Documents/DocumentData.php

48 lines
1.1 KiB
PHP
Raw Normal View History

<?php
namespace App\Models\Documents;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
class DocumentData extends Model
{
protected $table = 'document_data';
protected $fillable = [
'document_id',
'section_id',
'column_id',
'row_index',
'field_key',
'field_value',
];
protected $casts = [
'row_index' => 'integer',
];
// =========================================================================
// Relationships
// =========================================================================
public function document(): BelongsTo
{
return $this->belongsTo(Document::class);
}
// =========================================================================
// Scopes
// =========================================================================
public function scopeForSection($query, int $sectionId)
{
return $query->where('section_id', $sectionId);
}
public function scopeForField($query, string $fieldKey)
{
return $query->where('field_key', $fieldKey);
}
}