Production.php
563 字节
<?php
namespace app\common\model;
class Production extends BaseModel
{
// 追加属性
protected $append = [
'one_image'
];
/**
* 关联用户表
*/
public function User(){
return $this->belongsTo('user','user_id','id');
}
public function getOneImageAttr($value,$data)
{
$arr = explode(',',$data['images']);
foreach ($arr as $key => $val){
$arr[$key] = cdnurl($val);
}
if (empty($arr)){
return '';
}
return $arr[0];
}
}