| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 |
- <?php
- /**
- * Created by PhpStorm.
- * User: king/QQ:995265288
- * Date: 2019-07-08
- * Time: 10:30
- */
- namespace app\backend\models\excelRecharge;
- use app\common\scopes\UniacidScope;
- class RecordsModel extends \app\common\models\excelRecharge\RecordsModel
- {
- protected $appends = ['sourceName'];
- public static function boot()
- {
- parent::boot();
- self::addGlobalScope(new UniacidScope());
- }
- /**
- * 通过字段 source 输出 sourceName
- *
- * @return string
- * @Author yitian
- */
- public function getSourceNameAttribute()
- {
- return $this->getSourceNameComment($this->attributes['source']);
- }
- /**
- * @param $source
- * @return mixed|string
- */
- public function getSourceNameComment($source)
- {
- return isset($this->sourceComment()[$source]) ? $this->sourceComment()[$source] : '';
- }
- /**
- * @return array
- */
- public function sourceComment()
- {
- return [
- 'balance' => '余额',
- 'point' => '积分',
- 'love' => $this->loveName()
- ];
- }
- /**
- * @return string
- */
- private function loveName()
- {
- if (app('plugins')->isEnabled('love')) {
- return LOVE_NAME;
- }
- return "爱心值";
- }
- }
|