60], [['cover_pic'], 'string', 'max' => 255], ]; } /** * {@inheritdoc} */ public function attributeLabels() { return [ 'id' => 'ID', 'mall_id' => 'Mall ID', 'mch_id' => 'Mch ID', 'name' => '发货单名称', 'cover_pic' => '缩略图', 'params' => '模板参数', 'is_default' => '是否为默认模板0.否|1.是', 'created_at' => 'Created At', 'updated_at' => 'Updated At', 'deleted_at' => 'Deleted At', 'is_delete' => 'Is Delete', ]; } /** * @param OrderSendTemplate $template * @return array */ public function getNewData($template, $defaultParams = []) { $newTemplate = []; $newTemplate['id'] = $template->id; $newTemplate['name'] = $template->name; $newTemplate['cover_pic'] = $template->cover_pic; $newTemplate['is_default'] = $template->is_default; // 补充上新加的默认值 $params = json_decode($template->params, true); foreach ($defaultParams as $key => $value) { if (!isset($params[$key])) { $params[$key] = $value; } } $newTemplate['params'] = $params; return $newTemplate; } }