first commit
This commit is contained in:
45
app/Models/System/Config.php
Normal file
45
app/Models/System/Config.php
Normal file
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | SentCMS [ WE CAN DO IT JUST THINK IT ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2024 http://www.tensent.cn All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: molong <molong@tensent.cn> <http://www.tensent.cn>
|
||||
// +----------------------------------------------------------------------
|
||||
namespace App\Models\System;
|
||||
|
||||
use Illuminate\Database\Eloquent\Casts\Attribute;
|
||||
|
||||
class Config extends \App\Models\BaseModel {
|
||||
|
||||
protected $table = 'system_configs';
|
||||
protected $fillable = ['values', 'name', 'title', 'group', 'remark', 'type', 'status', 'sort'];
|
||||
protected $hidden = ['deleted_at'];
|
||||
|
||||
protected function casts(): array {
|
||||
return [
|
||||
'option' => 'json',
|
||||
];
|
||||
}
|
||||
|
||||
public function options(): Attribute {
|
||||
return Attribute::make(
|
||||
get: fn (mixed $value, array $data) => [
|
||||
'placeholder' => $data['title'],
|
||||
'options' => $data['option'] ? json_decode($data['option'], true) : [],
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
public function label() : Attribute {
|
||||
return Attribute::make(
|
||||
get: fn (mixed $value, array $data) => $data['title'],
|
||||
);
|
||||
}
|
||||
|
||||
public function prop() : Attribute {
|
||||
return Attribute::make(
|
||||
get: fn (mixed $value, array $data) => $data['title'],
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user