41 lines
835 B
PHP
41 lines
835 B
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
class CertificateTemplate extends Model
|
|
{
|
|
protected $fillable = [
|
|
'program_id', 'original_filename', 'image_path', 'config_json', 'is_active', 'uploaded_by',
|
|
];
|
|
|
|
protected function casts(): array
|
|
{
|
|
return [
|
|
'config_json' => 'array',
|
|
'is_active' => 'boolean',
|
|
];
|
|
}
|
|
|
|
public function program()
|
|
{
|
|
return $this->belongsTo(Program::class);
|
|
}
|
|
|
|
public function uploader()
|
|
{
|
|
return $this->belongsTo(User::class, 'uploaded_by');
|
|
}
|
|
|
|
public function certificates()
|
|
{
|
|
return $this->hasMany(Certificate::class);
|
|
}
|
|
|
|
public function getFieldConfig(string $field): ?array
|
|
{
|
|
return $this->config_json['fields'][$field] ?? null;
|
|
}
|
|
}
|