ModelAppendFieldTrait.php
1.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
<?php
/**
* +--------------------------------------------------------------------------------------------------------------------
* trait :model 需要添加字段 trait
* +--------------------------------------------------------------------------------------------------------------------
*
* PHP version 7
*
* @category App\Models\Traits
* @package App\Models\Traits
* @author Richer <yangzi1028@163.com>
* @date 2021年7月19日15:55:15
* @copyright 2020-2022 Richer (http://www.xxxxxx.com)
* @license http://www.xxxxxx.com License
* @link http://www.xxxxxx.com
*/
namespace App\Models\Traits;
use Illuminate\Support\Arr;
/**
* Trait ModelAppendFieldTrait
*
* @category App\Models\Traits
* @package App\Models\Traits
* @author Richer <yangzi1028@163.com>
* @date 2021年7月19日15:55:15
* @copyright 2020-2022 Richer (http://www.xxxxxx.com)
* @license http://www.xxxxxx.com License
* @link http://www.xxxxxx.com
*/
trait ModelAppendFieldTrait
{
/**
* 访问器被附加到模型数组的形式。
*
* @var array
*/
// protected $appends = ['status_show'];
/**
* 获取状态的中文显示
*
* @return mixed
*/
public function getStatusShowAttribute()
{
return __(Arr::get(config('constants.STATUS_OPTIONS'), $this->status ? : config('constants.STATUS_OK')));
}
}