Teren-app/app/Models/DocumentSetting.php

36 lines
946 B
PHP

<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class DocumentSetting extends Model
{
protected $fillable = [
'file_name_pattern',
'date_format',
'unresolved_policy',
'preview_enabled',
'whitelist',
'date_formats',
];
protected $casts = [
'preview_enabled' => 'boolean',
'whitelist' => 'array',
'date_formats' => 'array',
];
public static function instance(): self
{
return static::query()->first() ?? static::create([
'file_name_pattern' => config('documents.file_name_pattern'),
'date_format' => config('documents.date_format'),
'unresolved_policy' => config('documents.unresolved_policy'),
'preview_enabled' => config('documents.preview.enabled', true),
'whitelist' => config('documents.whitelist'),
'date_formats' => [],
]);
}
}