<?php
/**
 * @copyright   Copyright (c) 2017 https://www.sapixx.com All rights reserved.
 * @license     Licensed (http://www.apache.org/licenses/LICENSE-2.0).
 * @author      pillar<ltmn@qq.com>
 * 信息类型
 */
namespace app\citys\model;
use think\Model;

class CitysType extends Model{

    protected $pk = 'id';
    //添加或编辑
    public static function edit($param){
        $data['title']       = $param['title'];
        $data['endtips']     = $param['endtips'];
        $data['sort']        = $param['sort'];
        $data['price']       = $param['price'];
        $data['phone']       = $param['phone'];
        $data['update_time'] = time();
        if(isset($param['id'])){
            return self::update($data,['id'=>(int)$param['id']]);
        }else{
            $data['create_time']       = time();
            $data['member_miniapp_id'] = $param['member_miniapp_id'];
            return self::insert($data);
        }
    } 

    /**
     * 标题AS成Title
     * @param string $value
     * @param array $data
     * @return void
     */
    public function getNameAttr($value,$data)
    {
        return $data['title'];
    }
}