Demo.php 710 B

12345678910111213141516171819202122232425262728293031323334
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: 97
  5. */
  6. namespace app\common\model\mysql;
  7. use think\Model;
  8. class Demo extends Model{
  9. public function getStatusTextAttr($value,$data){
  10. $status = [
  11. 0 => '待审核',
  12. 1 => '正常',
  13. 2 => '错误',
  14. 99 => '删除',
  15. ];
  16. return $status[$data['status']];
  17. }
  18. public function getDemoDataByCategoryId($categoryId,$limit = 10){
  19. if(empty($categoryId)){
  20. return [];
  21. }
  22. $results = $this->where("category_id",$categoryId)
  23. ->limit($limit)
  24. ->order("id","desc")
  25. ->select()
  26. ->toArray();
  27. return $results;
  28. }
  29. }