where(['app_id' => self::$app_id])->select(); $config = []; foreach ($data as $item) { $config[$item['key']] = $item; } return array_merge_multiple($self->defaultData(), $config); } /** * 获取设置项信息 */ public static function getItem($key, $app_id = null) { if (is_null($app_id)) { $app_id = static::$app_id; } return static::where(['key' => $key, 'app_id' => $app_id])->value('values', true); } /** * 获取设置项 */ public static function detail($key) { return (new static())->find(compact('key')); } /** * 默认配置 */ public function defaultData() { return [ 'basic' => [ 'key' => 'basic', 'describe' => '基础设置', 'values' => [ // 置顶金额 'top_amount' => '10', // 置顶天数 'top_days' => '7', ] ], 'background' => [ 'key' => 'background', 'describe' => '页面背景图', 'values' => [ // 数字资产图片1 'digital_asset_1' => '', // 数字资产图片2 'digital_asset_2' => '', ] ] ]; } }