123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- <?php
- namespace App\Models;
- use App\Traits\ModelHelpers;
- use Illuminate\Database\Eloquent\Model;
- class CardRiding extends Model
- {
- use ModelHelpers;
- protected $table = 'card_riding';
- 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'];
- const LIMIT_TIMES_YES = 1;
- const LIMIT_TIMES_NO = 0;
- public static $limitTimesMaps = [
- self::LIMIT_TIMES_NO => '不限次',
- self::LIMIT_TIMES_YES => '限次',
- ];
- const DISCOUNT_YES = 1;
- const DISCOUNT_NO = 0;
- public static $discountMaps = [
- self::DISCOUNT_NO => '无折扣',
- self::DISCOUNT_YES => '有折扣',
- ];
- const STATUS_OK = 1;
- const STATUS_NO = 0;
- public static $statusMaps = [
- self::STATUS_OK=>'启用',
- self::STATUS_NO=>'停用',
- ];
- const GIVE_OK = 1;
- const GIVE_NO = 0;
- public static $giveMaps = [
- self::GIVE_OK=>'可赠送',
- self::GIVE_NO=>'不可赠送',
- ];
- public function areaRidingCard(){
- return $this->belongsToMany(
- Area::class,
- 'card_riding_area',
- 'riding_card_id',
- 'area_id'
- )->withTimestamps();
- }
- public function delete()
- {
- $this->areaRidingCard()->detach();
- return parent::delete();
- }
- //
- // public function card(){
- // return $this->morphMany(InviteNewUsersGiveGiftLog::class,'gift','card','id');
- // }
- }
|