123456789101112131415161718192021222324252627282930313233343536373839404142434445 |
- <?php
- namespace App\Modules\Book\Models;
- use Illuminate\Database\Eloquent\Model;
- class Book extends Model
- {
- 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;
- }
- /**
- * @param $bids
- * @return mixed
- */
- public static function getBooksByIds($bids)
- {
- if (empty($bids)) {
- return [];
- }
- return self::whereIn('id', $bids)->get();
- }
- }
|