refactor: susun semula struktur folder — Laravel source ke src/
This commit is contained in:
40
src/app/Models/CertificateTemplate.php
Normal file
40
src/app/Models/CertificateTemplate.php
Normal file
@@ -0,0 +1,40 @@
|
||||
<?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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user