123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172 |
- <?php
- namespace app\api\model;
- use think\Cache;
- use think\Model;
- class IntroduceModel extends Model
- {
- protected $name = 'introduce';
- // protected $resultSetType = 'collection';
- public function allIntroduce()
- {
- $data = $this->alias('i')
- ->join('type t', 'i.tid=t.id','left')
- ->field('t.name name,title,zhu_image,pei_images,introduce')
- ->order('i.sort','asc')
- ->select();
- if ($data) {
- return json(['data' => $data, 'msg'=> '', 'code' => 200]);
- } else {
- return json(['data' => [], 'msg' => '暂无数据','code' => 100]);
- }
- }
- public function introduce($id)
- {
- $data = $this->alias('i')
- ->join('type t', 'i.tid=t.id','left')
- ->field('t.name name,title,zhu_image,pei_images,introduce')
- ->where('i.tid',$id)
- ->order('i.sort','asc')
- ->select();
- if ($data) {
- return json(['data' => $data, 'msg'=> '', 'code' => 200]);
- } else {
- return json(['data' => [], 'msg' => '暂无数据','code' => 100]);
- }
- }
- public function introduceInfo($id)
- {
- $data = $this->alias('i')
- ->join('type t', 'i.tid=t.id','left')
- ->field('t.name name,title,zhu_image,pei_images,introduce')
- ->where('i.id',$id)
- ->order('i.sort','asc')
- ->select();
- if ($data) {
- return json(['data' => $data, 'msg'=> '', 'code' => 200]);
- } else {
- return json(['data' => [], 'msg' => '暂无数据','code' => 100]);
- }
- }
- public function type()
- {
- $this->belongsTo('type','tid', 'id');
- }
- public function getZhuImageAttr($value)
- {
- return config('site.url').$value;
- }
- public function getPeiImagesAttr($value)
- {
- $value = explode(',', $value);
- foreach ($value as &$v) {
- $v = config('site.url').$v;
- }
- return $value;
- }
- }
|