CardRiding.php 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <?php
  2. namespace App\Models;
  3. use App\Traits\ModelHelpers;
  4. use Illuminate\Database\Eloquent\Model;
  5. class CardRiding extends Model
  6. {
  7. use ModelHelpers;
  8. protected $table = 'card_riding';
  9. protected $fillable = ['name','is_limit_times','effective_days','times','day_can_ridding_times','price','discount','is_discount','status','admin_id','deduction_money','is_give','merchant_id'];
  10. const LIMIT_TIMES_YES = 1;
  11. const LIMIT_TIMES_NO = 0;
  12. public static $limitTimesMaps = [
  13. self::LIMIT_TIMES_NO => '不限次',
  14. self::LIMIT_TIMES_YES => '限次',
  15. ];
  16. const DISCOUNT_YES = 1;
  17. const DISCOUNT_NO = 0;
  18. public static $discountMaps = [
  19. self::DISCOUNT_NO => '无折扣',
  20. self::DISCOUNT_YES => '有折扣',
  21. ];
  22. const STATUS_OK = 1;
  23. const STATUS_NO = 0;
  24. public static $statusMaps = [
  25. self::STATUS_OK=>'启用',
  26. self::STATUS_NO=>'停用',
  27. ];
  28. const GIVE_OK = 1;
  29. const GIVE_NO = 0;
  30. public static $giveMaps = [
  31. self::GIVE_OK=>'可赠送',
  32. self::GIVE_NO=>'不可赠送',
  33. ];
  34. public function areaRidingCard(){
  35. return $this->belongsToMany(
  36. Area::class,
  37. 'card_riding_area',
  38. 'riding_card_id',
  39. 'area_id'
  40. )->withTimestamps();
  41. }
  42. public function delete()
  43. {
  44. $this->areaRidingCard()->detach();
  45. return parent::delete();
  46. }
  47. //
  48. // public function card(){
  49. // return $this->morphMany(InviteNewUsersGiveGiftLog::class,'gift','card','id');
  50. // }
  51. }