SuperiorHistoryBooks.php 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. <?php
  2. namespace App\Modules\Book\Models;
  3. use Illuminate\Database\Eloquent\Model;
  4. class SuperiorHistoryBooks extends Model
  5. {
  6. protected $table = 'superior_history_book';
  7. protected $fillable = ['id','bid', 'pid', 'category_id','status','created_at', 'updated_at',
  8. 'recommend_index','uv','register_uv_rate','force_sub_rate','pay_force_sub_rate','pay_uv_rate','charge_uv_rate','order_index','level'];
  9. public static function getSuperiorList($pid,$page_size=15,$paginate=true,$search=[]){
  10. $filter = [
  11. ['superior_history_book.status','=',1],
  12. ['book_configs.is_on_shelf','>=',1],
  13. ['book_configs.is_on_shelf','<=',2]
  14. ];
  15. if($pid){
  16. $filter[] = ['superior_history_book.pid','=',$pid];
  17. }
  18. if($search){
  19. $filter = array_merge($filter,$search);
  20. }
  21. $res = self::where($filter)
  22. ->select(['superior_history_book.id','superior_history_book.bid','superior_history_book.register_uv_rate','superior_history_book.pay_uv_rate','superior_history_book.charge_uv_rate','book_configs.book_name','superior_history_book.pid','superior_history_book.created_at','superior_history_book.order_index'])
  23. ->leftjoin('book_configs','book_configs.bid','=','superior_history_book.bid')
  24. ->orderBy('superior_history_book.order_index','asc')
  25. ->orderBy('superior_history_book.recommend_index','desc')
  26. ->orderBy('superior_history_book.id','asc');
  27. if($paginate){
  28. $res = $res->paginate($page_size);
  29. }else{
  30. $res = $res->get();
  31. }
  32. return $res;
  33. }
  34. }