<?php
/**
 * Created by PhpStorm.
 * User: Lenovo
 * Date: 2018/9/25
 * Time: 15:20
 */

namespace App\Models;


class ArticleType extends BaseModel
{
    protected $table    =   "article_type";
    public $timestamps  =   false;

     function type(){
     return   $this->orderBy('sort', 'desc')->get()->toArray();
    }

    function addType($data){
        $res=$this->insert($data);
        if(!$res){
            return -6030001222;
        }
    }

    function getlist($where,$limit ){
      return  $this->where($where)
            ->limit($limit)
            ->get()
            ->toArray();
    }

    function getIdData(int $id){
         return $this->where("id",$id)->first();
    }

    public function updateIdData(int  $id,$data){
         return $this->where("id",$id)->update($data);
    }

    function getGrade($id){
         $deep  =   $this->where("id",$id)->first();
         return isset($deep["parent_path"])&&!empty($deep["parent_path"])?($deep["parent_path"]).">".$deep["cate_name"]:$deep["cate_name"];
    }
}