説明なし

CustomerVip.php 942B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: shensong
  5. * Date: 2019/11/27
  6. * Time: 17:06
  7. */
  8. namespace App;
  9. use Illuminate\Database\Eloquent\Model;
  10. class CustomerVip extends Model
  11. {
  12. public $timestamps = false;
  13. protected $table = 'customer_vip';
  14. /**
  15. * 获取会员信息
  16. * @param $phone
  17. * @return mixed
  18. */
  19. public static function getCustomerInformation($phone){
  20. $self = new self();
  21. $date = date('Y-m-d');
  22. $info = $self->where('phone',$phone)->where('is_del',0)->where('vip_end_time','>=',$date)->first();
  23. return $info;
  24. }
  25. /**
  26. * 判断用户是否为会员
  27. * @param $phone
  28. * @return bool
  29. */
  30. public static function judgeWhetherTheUserIsAMember($phone){
  31. $info = CustomerVip::getCustomerInformation($phone);
  32. if(!$info || (strtotime($info->vip_end_time) < time())){
  33. return false;
  34. }
  35. return true;
  36. }
  37. }