From 915af1b284020bfae21292839fc2921afbb9936d Mon Sep 17 00:00:00 2001 From: lanzu_qinsheng <334039090@qq.com> Date: Wed, 16 Sep 2020 11:24:11 +0800 Subject: [PATCH] =?UTF-8?q?=E7=A4=BE=E5=8C=BA=20=E4=BD=BF=E7=94=A8=20first?= =?UTF-8?q?Create?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Admin/Controllers/LanzuCsInfoController.php | 5 ++++- app/Models/LanzuUserBalance.php | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/app/Admin/Controllers/LanzuCsInfoController.php b/app/Admin/Controllers/LanzuCsInfoController.php index 33fdc95..a50ed58 100644 --- a/app/Admin/Controllers/LanzuCsInfoController.php +++ b/app/Admin/Controllers/LanzuCsInfoController.php @@ -49,7 +49,10 @@ class LanzuCsInfoController extends AdminController return LanzuUserRelationBind::getCount($this->admin_user_id); }); $grid->column('balance', '可提现金额')->display(function (){ - $balance = LanzuUserBalance::where('source_id',$this->admin_user_id)->where('user_type',4)->first(); + $balance = LanzuUserBalance::firstOrCreate( + ['source_id'=>$this->admin_user_id,'user_type'=>Type::BALANCE_USER_TYPE_CS], + ['balance'=>0] + ); return $balance->balance; }); $grid->column('qrcode_path', '二维码')->image('', 50, 50); diff --git a/app/Models/LanzuUserBalance.php b/app/Models/LanzuUserBalance.php index bd585be..fb46939 100644 --- a/app/Models/LanzuUserBalance.php +++ b/app/Models/LanzuUserBalance.php @@ -10,7 +10,7 @@ class LanzuUserBalance extends Model { protected $table = 'lanzu_user_balance'; protected $dateFormat = 'U'; - + protected $guarded = []; /** * 获取可提现金额 * @param $uid