44 lines
931 B
PHP
44 lines
931 B
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
class UserVip extends Model
|
|
{
|
|
use HasFactory;
|
|
|
|
const STATUS_UNPAID = 0;
|
|
const STATUS_SUCCESS = 1;
|
|
const STATUS_PROCESSING = 2;
|
|
|
|
protected $fillable = ['user_id', 'vip_id', 'name', 'price', 'times', 'gift', 'status', 'success_time'];
|
|
|
|
protected $casts = [
|
|
'times' => 'json',
|
|
'gift' => 'json'
|
|
];
|
|
|
|
public static $statusMap = [
|
|
self::STATUS_UNPAID => '待付款',
|
|
self::STATUS_SUCCESS => '已付款',
|
|
self::STATUS_PROCESSING => '处理中'
|
|
];
|
|
|
|
public function user()
|
|
{
|
|
return $this->belongsTo(User::class, 'user_id');
|
|
}
|
|
|
|
public function vip()
|
|
{
|
|
return $this->belongsTo(Vip::class, 'vip_id');
|
|
}
|
|
|
|
public function pay()
|
|
{
|
|
return $this->morphOne(PayLog::class, 'payable');
|
|
}
|
|
}
|