<?php namespace App\Modules\Book\Models; use Illuminate\Database\Eloquent\Model; class Book extends Model { protected $connection = 'api_mysql'; protected $table = 'books'; protected $fillable = ['ly_bid','name','author','intro','cover','category_name','keyword', 'category_id','status','chapter_count','first_cid','last_cid','size','last_chapter','sequence']; /** * 获取分类id * @return array */ public static function getCategoryId(){ $res = self::select('category_id')->distinct()->get()->toArray(); $data = []; foreach ($res as $v){ array_push($data,$v['category_id']); } return $data; } /** * 获取book * @return array */ public static function getBook($bid){ $res = self::select('*')->where('id',$bid)->first(); return $res; } }