Platform.php 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <?php
  2. declare (strict_types = 1);
  3. namespace app\model\system;
  4. use library\basic\BaseModel;
  5. use library\traits\JwtAuthModelTrait;
  6. use library\traits\ModelTrait;
  7. use think\Model;
  8. /**
  9. * @mixin \think\Model
  10. */
  11. class Platform extends BaseModel
  12. {
  13. use ModelTrait;
  14. use JwtAuthModelTrait;
  15. private $platformData;
  16. /**
  17. * 根据id查询平台
  18. * @param $id
  19. * @param string $field
  20. * @return mixed
  21. */
  22. public function getPlatformId($id,$field = '*') {
  23. $this->getPlatformData();
  24. if(!empty($this->platformData)) {
  25. foreach ($this->platformData as $v) {
  26. if ($v['id'] == $id) {
  27. return $field == '*' ? $v : $v[$field];
  28. }
  29. }
  30. }
  31. return null;
  32. }
  33. /**
  34. * 平台数据
  35. * @return mixed|\think\Collection
  36. * @throws \think\db\exception\DataNotFoundException
  37. * @throws \think\db\exception\DbException
  38. * @throws \think\db\exception\ModelNotFoundException
  39. */
  40. public function getPlatformData(){
  41. if(empty($this->platformData))
  42. $this->platformData = $this->order("seq desc")->select();
  43. return $this->platformData;
  44. }
  45. }