审查视图

application/api/model/Goods.php 1.1 KB
李忠强 authored
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
<?php


namespace app\api\model;


use think\Model;

class Goods extends Model
{
    protected $name = 'litestore_goods';
    protected $append = [
        'image_text',
        'images_text',
        'down_image_text',
        'four_image_text'
    ];

    public function getImageTextAttr($value,$data)
    {
        $value = !empty($data['image']) ? cdnurl($data['image'],true):'';
        return $value;
    }

    public function getFourImageTextAttr($value,$data)
    {
        $value = !empty($data['four_image']) ? explode(',',$data['four_image']):[];
        foreach ($value as $key => &$val){
            $val = cdnurl($val,true);
        }
        return $value;
    }

    public function getImagesTextAttr($value,$data)
    {
        $value = !empty($data['images']) ? explode(',',$data['images']):[];
        foreach ($value as $key => &$val){
            $val = cdnurl($val,true);
        }
        return $value;
    }

    public function getDownImageTextAttr($value,$data)
    {
        $value = !empty($data['down_image']) ? cdnurl($data['down_image'],true):'';
        return $value;
    }
}