CardInfoModel.php 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. <?php
  2. namespace App\Models;
  3. use App\Models\BaseModel;
  4. use Illuminate\Database\Eloquent\SoftDeletes;
  5. /**
  6. * @description 抵扣卡列表
  7. * @author system;
  8. * @version 1.0
  9. * @date 2018-07-12 08:35:58
  10. *
  11. */
  12. class CardInfoModel extends BaseModel
  13. {
  14. use SoftDeletes;
  15. /**
  16. * 数据表名
  17. *
  18. * @var string
  19. *
  20. */
  21. protected $table = 'card_info';
  22. /**
  23. * 主键
  24. */
  25. protected $primaryKey = 'id';
  26. //分页
  27. protected $perPage = PAGE_NUMS;
  28. /**
  29. * 可以被集体附值的表的字段
  30. *
  31. * @var string
  32. */
  33. protected $fillable = [
  34. 'card_no',
  35. 'status',
  36. 'user_id',
  37. 'remark',
  38. 'end_time',
  39. 'product_id',
  40. 'qrcode',
  41. 'used_at'
  42. ];
  43. public function status(){
  44. switch ($this->status){
  45. case 1:
  46. return '已激活';
  47. break;
  48. case 2:
  49. return '已核销';
  50. break;
  51. default:
  52. return '未激活';
  53. break;
  54. }
  55. }
  56. public function product(){
  57. $product = (new ProductInfoModel())->whereIn('id',explode(',',$this->product_id))->pluck('name');;
  58. return $product;
  59. }
  60. }