12345678910111213141516171819202122232425262728293031323334 |
- <?php
- /**
- * Created by PhpStorm.
- * User: 97
- */
- namespace app\common\model\mysql;
- use think\Model;
- class Demo extends Model{
- public function getStatusTextAttr($value,$data){
- $status = [
- 0 => '待审核',
- 1 => '正常',
- 2 => '错误',
- 99 => '删除',
- ];
- return $status[$data['status']];
- }
- public function getDemoDataByCategoryId($categoryId,$limit = 10){
- if(empty($categoryId)){
- return [];
- }
- $results = $this->where("category_id",$categoryId)
- ->limit($limit)
- ->order("id","desc")
- ->select()
- ->toArray();
- return $results;
- }
- }
|