FanGet.php 632 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. <?php
  2. namespace catchAdmin\fan\model\get;
  3. use think\facade\Db;
  4. trait FanGet
  5. {
  6. public function getWindNameAttr()
  7. {
  8. $wind_id = $this->wind_id;
  9. $wind_name = Db::name('wind')->where('id',$wind_id)->value('name');
  10. return $wind_name;
  11. }
  12. public function getImgAttr()
  13. {
  14. $data = $this->getData('img');
  15. if(empty($data))
  16. {
  17. $data = [];
  18. }
  19. else
  20. {
  21. $data = json_decode($data,true);
  22. }
  23. return $data;
  24. }
  25. public function setImgAttr($value)
  26. {
  27. return json_encode($value);
  28. }
  29. }