state = 'INIT'; $model->trade_no = 'T' . date('ymdHis') . sprintf("%07d", mt_rand(0, pow(10, 7) - 1)); }); } public function order() { return $this->belongsTo(Order::class); } protected function getTypeTextAttribute() { if($this->type == 'BALANCE'){ return '余额支付'; }elseif($this->type == 'WECHAT'){ return '微信支付'; }else{ return $this->type; } } protected function getStateTextAttribute() { if($this->state == 'SUCCESS'){ return '支付完成'; }elseif($this->state == 'INIT'){ return '待支付'; }else{ return $this->state; } } }