41 lines
822 B
PHP
41 lines
822 B
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use App\User;
|
|
|
|
class VipPament extends Model
|
|
{
|
|
public static function boot()
|
|
{
|
|
parent::boot();
|
|
|
|
self::creating(function ($model) {
|
|
if (!$model->state) {
|
|
$model->state = 'INIT';
|
|
}
|
|
$model->trade_no = 'T' . date('ymdHis') . sprintf("%07d", mt_rand(0, pow(10, 7) - 1));
|
|
});
|
|
}
|
|
|
|
public function getPayTypeAttribute()
|
|
{
|
|
switch ($this->type) {
|
|
case 'WECHAT':
|
|
return '微信支付';
|
|
break;
|
|
case 'CDKEY':
|
|
return '激活码';
|
|
break;
|
|
default:
|
|
return '无';
|
|
break;
|
|
}
|
|
}
|
|
|
|
public function user()
|
|
{
|
|
return $this->belongsTo(User::class);
|
|
}
|
|
}
|