33 lines
855 B
PHP
33 lines
855 B
PHP
|
|
<?php
|
||
|
|
|
||
|
|
namespace App\Modules\CustomField\Models;
|
||
|
|
|
||
|
|
use Database\Factories\CustomFieldDefinitionFactory;
|
||
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||
|
|
use Illuminate\Database\Eloquent\Model;
|
||
|
|
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||
|
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
||
|
|
|
||
|
|
class CustomFieldDefinition extends Model
|
||
|
|
{
|
||
|
|
use HasFactory, SoftDeletes;
|
||
|
|
|
||
|
|
protected $fillable = ['label', 'key', 'type', 'options', 'is_required', 'sort_order'];
|
||
|
|
|
||
|
|
protected $casts = [
|
||
|
|
'type' => CustomFieldType::class,
|
||
|
|
'options' => 'array',
|
||
|
|
'is_required' => 'boolean',
|
||
|
|
];
|
||
|
|
|
||
|
|
public function values(): HasMany
|
||
|
|
{
|
||
|
|
return $this->hasMany(CustomFieldValue::class);
|
||
|
|
}
|
||
|
|
|
||
|
|
protected static function newFactory(): CustomFieldDefinitionFactory
|
||
|
|
{
|
||
|
|
return CustomFieldDefinitionFactory::new();
|
||
|
|
}
|
||
|
|
}
|