BookPromotionChecked.php 949 B

123456789101112131415161718192021222324252627282930313233
  1. <?php
  2. namespace App\Modules\Book\Models;
  3. use Illuminate\Database\Eloquent\Model;
  4. class BookPromotionChecked extends Model
  5. {
  6. protected $table = 'book_promotion_info_checked';
  7. protected $fillable = ['id', 'book_id', 'book_name', 'cp_source', 'operator', 'status', 'size', 'is_on_shelf',
  8. 'recharge_amount_in_24h_outside', 'recharge_amount_in_24h_inside', 'recharge_amount_in_72h_inside',
  9. 'recharge_amount_in_72h_outside', 'periods', 'onshelf_date', 'author', 'updated_at', 'created_at'];
  10. static function getInfo($periods,$isAll)
  11. {
  12. $search_object = self::orderBy('created_at', 'desc');
  13. if ($periods){
  14. $search_object->where('periods',$periods);
  15. }
  16. if ($isAll) {
  17. return $search_object->get();
  18. } else {
  19. return $search_object->paginate();
  20. }
  21. }
  22. static function getMaxPeriod()
  23. {
  24. return self::max('periods')+1;
  25. }
  26. }