| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990 |
- <?php
- namespace App\Models;
- class Article extends BaseModel {
- protected $table = "article";
- public $timestamps = false;
- function getlist($list = 10, $where = '') {
- $data = $this->select('title', 'id', 'time', 'type','child_id','sort','status','typebind')->orderBy('time', 'desc')->where('type', '!=', 8)->where('type', '!=', 9);
- if (!empty($where) && is_array($where)) {
- $data = $data->where($where);
- }
- $data = $data->paginate($list);
- if (!$data) {
- return -4010010022; //没有数据
- }
- return $data->toArray();
- }
- //获取信息
- function getMsg($value, $type) {
- $fild = $this->getfild($type);
- $data = $this->select('id', 'time', 'title')->where($fild, $value)->orderBy('time', 'desc')->limit(10)->get();
- if (!$data) {
- return -4010010122; //没有数据
- }
- return $data->toArray();
- }
- function getDmsg($value, $type) {
- $fild = $this->getfild($type);
- $data = $this->select('id', 'time', 'title', 'content','img','author','type','sort','child_id','mobilecontent','mobileimg','typebind')->where($fild, $value)->first();
- if (!$data) {
- return -4010010122; //没有数据
- }
- return $data->toArray();
- }
- function getfild($k) {
- $a = array(
- 1 => 'id',
- 2 => 'type',
- );
- return $a[$k];
- }
- function updateMsg($data, $id) {
- $res = $this->where('id', $id)->update($data);
- if (!$res) {
- return -4010011122;
- }
- return 1;
- }
- //添加公告数据
- function addNotice($data){
- $res=$this->insert($data);
- if(!$res){
- return -6030001222;
- }
- }
- //获取内容
- function getContent($type){
- $data=$this->where('type',$type)->orderBy('time', 'asc')->first();
- if(!$data){
- return -4010010022; //没有数据
- }
- return $data->toArray();
- }
- //更新内容
- function updateContent($data,$type){
- //检查是否存在
- $check=$this->getContent($type);
- if(!$check<0){
- $data['type']=$type;
- $data['identity']=UUID();
- $res=$this->insert($data);
- }else{
- $res=$this->where('type',$type)->orderBy('time', 'asc')->update($data);
- }
- if(!$res){
- return -4010011122;
- }
- return 1;
- }
- public function closeGame($where,$data){
- return $this->where($where)->update($data);
- }
- }
|