1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
- <?php
- namespace app\sub\controller;
- use app\common\model\Mobile as M;
- use app\common\model\MobileHoldLog;
- use think\Db;
- /**
- * 会员中心
- */
- class Mobile extends SubCommon
- {
- protected $noNeedLogin=[];
- protected $noNeedRight="*";
- public function edit(){
- $data=input();
- $mobile=M::where('s_id',$this->auth->id)->findOrFail($data['id']);
- if($this->request->isGet()){
- $this->validate($data,[
- 'id'=>'require',
- ]);
- $this->assign('mobile',$mobile);
- return view();
- }else{
- $this->validate($data,[
- 'amount_base'=>['require','number','gt:0'],
- ]);
- foreach ($this->request->only('amount_base') as $key=>$value){
- $mobile[$key]=$value;
- }
- $mobile->save();
- $this->success();
- }
- }
- #修改预占
- public function hold(){
- $data=input();
- $user=$this->auth->getUser();
- $this->validate($data,[
- 'id'=>['require','integer'],
- 'is_hold'=>['require','in:0,1'],
- ]);
- $mobile=M::where('s_id',$this->auth->id)->findOrFail($data['id']);
- Db::startTrans();
- $mobile['is_hold']=$data['is_hold'];
- $mobile->save();
- $mobile->holdLog()->save(MobileHoldLog::withHoldUser($user,$data['is_hold']));
- Db::commit();
- $this->success();
- }
- }
|