TicketModel.php 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. <?php
  2. namespace App\Models;
  3. use Illuminate\Database\Eloquent\Model;
  4. /**
  5. * App\Models\TicketModel
  6. *
  7. * @property int $id
  8. * @property string $name 名称
  9. * @property string $description 说明
  10. * @property string $code 兑换码
  11. * @property int $type 类型=6超级会员72h解锁卡
  12. * @property int|null $uid 所属用户
  13. * @property int $state 状态
  14. * @property int $get_time 领取时间
  15. * @property int $create_time 生成时间
  16. * @property int|null $validity_time 有效期
  17. * @property \Illuminate\Support\Carbon $created_at 创建时间
  18. * @property \Illuminate\Support\Carbon $updated_at 修改时间
  19. * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TicketModel newModelQuery()
  20. * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TicketModel newQuery()
  21. * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TicketModel query()
  22. * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TicketModel whereCode($value)
  23. * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TicketModel whereCreateTime($value)
  24. * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TicketModel whereCreatedAt($value)
  25. * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TicketModel whereDescription($value)
  26. * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TicketModel whereGetTime($value)
  27. * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TicketModel whereId($value)
  28. * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TicketModel whereName($value)
  29. * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TicketModel whereState($value)
  30. * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TicketModel whereType($value)
  31. * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TicketModel whereUid($value)
  32. * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TicketModel whereUpdatedAt($value)
  33. * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TicketModel whereValidityTime($value)
  34. * @mixin \Eloquent
  35. * @deprecated
  36. */
  37. class TicketModel extends Model
  38. {
  39. protected $table = "kdgx_partner_charge_user_ticket";
  40. protected $dateFormat = 'U';
  41. public $fillable = [
  42. 'name',
  43. 'description',
  44. 'code',
  45. 'type',
  46. 'uid',
  47. 'state',
  48. 'get_time',
  49. 'create_time',
  50. 'validity_time'
  51. ];
  52. public function getUseableByUid(int $uid, array $types)
  53. {
  54. $tickets = $this->where([
  55. ['uid', $uid],
  56. ['state', 0],
  57. ['validity_time', '>', time()]
  58. ])->whereIn('type', $types)->orderBy('get_time', 'desc')->get();
  59. return $tickets;
  60. }
  61. }