CardInfoModel.php 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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. 'price',
  36. 'status',
  37. 'user_id',
  38. 'remark',
  39. 'end_time',
  40. 'product_id',
  41. 'min_price',
  42. 'qrcode'
  43. ];
  44. public function status(){
  45. switch ($this->status){
  46. case 1:
  47. return '已激活';
  48. break;
  49. case 2:
  50. return '已核销';
  51. break;
  52. default:
  53. return '未激活';
  54. break;
  55. }
  56. }
  57. public function product(){
  58. $product = (new ProductCategoryModel())->whereIn('id',explode(',',$this->product_id))->pluck('name');;
  59. return $product;
  60. }
  61. }