namespace app\api\model;
class Theme extends BaseModel
{
public function topicImg(){
return $this->belongsTo('Image','topic_img_id','id');
}
public function headImg(){
return $this->belongsTo('Image','head_img_id','id');
}
public function themeProduct(){
return $this->hasMany('theme_produce','theme_id','id');
}
}namespace app\api\controller\v1;
use app\api\model\Theme as ThemeModel;
use app\api\validate\IDCollection;
class Theme
{
public function getSimpleList($ids=''){
(new IDCollection())->goCheck();
$ids =explode(',',$ids);
$result = ThemeModel::with('topicImg,headImg')->paginate($ids);
var_dump($result);
}
}
最佳答案