| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172 |
- <?php
- namespace App\Models;
- class GameCategory extends BaseModel
- {
- protected $table="game_category";
- public $timestamps = false;
- function getGameCategoryList($list=10)
- {
- $data = $this->select('id','name','codes','sort','is_show')->orderBy('sort','desc')->paginate($list);
- if(!$data){
- return -5040000522;//没有数据
- }
- $data = $data->toArray();
- $show = trans ('category.show');
- foreach ($data['data'] as $key => $val)
- {
- $data['data'][$key]['is_show'] = $show[$val['is_show']];
- }
- return $data;
- }
- function getCateOne($id){
- $data=$this->where('id',$id)->first();
- if(!$data){
- return -5040000622;
- }
- return $data->toArray();
- }
- //更新分类信息
- function updateOne($data,$id){
- $res=$this->where('id',$id)->update($data);
- if(!$res){
- return -5040000122;
- }
- return 1;
- }
- //检测是否存在
- function checkCopyCate($name)
- {
- $data=$this->where('name',$name)->first();
- if(!$data){
- return 1;
- }
- return -5040451122;
- }
- //检测分类代码是否存在
- function checkCopyCateCode($code)
- {
- $data=$this->where('codes',$code)->first();
- if(!$data){
- return 1;
- }
- return -5040451122;
- }
- function addCate($data)
- {
- $res=$this->insert($data);
- if(!$res){
- return -5040001122;
- }
- }
- function getAll()
- {
- $data = $this->select('id','name')->orderBy('id','asc')->get()->toArray();
- if(!$data){
- return $data = [ '暂无分类' ]; //没有数据
- }
- return $data;
- }
- }
|