55 lines
1.2 KiB
PHP
55 lines
1.2 KiB
PHP
|
|
<?php
|
||
|
|
|
||
|
|
namespace App\Models\ESign;
|
||
|
|
|
||
|
|
use Illuminate\Database\Eloquent\Model;
|
||
|
|
|
||
|
|
class EsignVerificationTemplate extends Model
|
||
|
|
{
|
||
|
|
protected $table = 'esign_verification_templates';
|
||
|
|
|
||
|
|
protected $fillable = [
|
||
|
|
'tenant_id',
|
||
|
|
'name',
|
||
|
|
'category',
|
||
|
|
'steps',
|
||
|
|
'pass_threshold',
|
||
|
|
'max_attempts',
|
||
|
|
'is_active',
|
||
|
|
'created_by',
|
||
|
|
'options',
|
||
|
|
];
|
||
|
|
|
||
|
|
protected $casts = [
|
||
|
|
'steps' => 'array',
|
||
|
|
'pass_threshold' => 'decimal:2',
|
||
|
|
'max_attempts' => 'integer',
|
||
|
|
'is_active' => 'boolean',
|
||
|
|
'options' => 'array',
|
||
|
|
];
|
||
|
|
|
||
|
|
public function scopeForTenant($query, $tenantId)
|
||
|
|
{
|
||
|
|
return $query->where('tenant_id', $tenantId);
|
||
|
|
}
|
||
|
|
|
||
|
|
public function scopeActive($query)
|
||
|
|
{
|
||
|
|
return $query->where('is_active', true);
|
||
|
|
}
|
||
|
|
|
||
|
|
public function getOption(string $key, mixed $default = null): mixed
|
||
|
|
{
|
||
|
|
$options = $this->options ?? [];
|
||
|
|
|
||
|
|
return $options[$key] ?? $default;
|
||
|
|
}
|
||
|
|
|
||
|
|
public function setOption(string $key, mixed $value): void
|
||
|
|
{
|
||
|
|
$options = $this->options ?? [];
|
||
|
|
$options[$key] = $value;
|
||
|
|
$this->options = $options;
|
||
|
|
}
|
||
|
|
}
|