瀏覽代碼

Merge branch 'gq' of http://git.9026.com/roobe/miao

Mike 7 年之前
父節點
當前提交
97f5aa8296

+ 31 - 1
server/app/Http/Controllers/Admin/User/InfoController.php

xqd
@@ -73,8 +73,38 @@ class InfoController extends Controller
     public function create(Request $reqeust)
     {
         if($reqeust->method() == 'POST') {
+            $validator = \Validator::make($reqeust->all(),
+                [
+                    'data.address'  => 'required',
+                    'data.phone'  => 'required|unique:user_info,phone',
+                    'data.sex'  => 'required',
+                    'data.emotion'  => 'required',
+                ],
+                [
+                    'data.address.required'  => '请选择省市区地址',
+                    'data.sex.required'  => '请选择性别',
+                    'data.phone.unique'  => '电话号码唯一',
+                    'data.emotion.required'  => '请选择情感状态',
+                ]
+            );
+            if($validator->fails()){
+                $url[] = array('url'=>U( 'User/Info/index'),'title'=>'返回列表');
+                return $this->showWarning($validator->messages()->all(),$url);
+            }
+
+            $avatar =  request('avatar');
+            $data = (array) request('data');
+            $data['avatar'] = getenv('APP_URL').$avatar;
+            $id = $this->repository->create($data);
+            if($id) {
+                $url[] = array('url'=>U( 'User/Info/index'),'title'=>'返回列表');
+                $url[] = array('url'=>U( 'User/Info/create'),'title'=>'继续添加');
+                $this->showMessage('添加成功',$url);
+            }else{
+                $url[] = array('url'=>U( 'User/Info/index'),'title'=>'返回列表');
+                return $this->showWarning('添加失败',$url);
+            }
 
-            return $this->_createSave();
         }
         return view('admin.user.info.edit');
     }

+ 2 - 1
server/app/Http/Controllers/Api/V1/Controller.php

xqd
@@ -20,7 +20,8 @@ class Controller extends BaseController
 
     public function getUser()
     {
-        $this->user = UserInfoModel::where('phone','13880642880')->first();
+//        $this->user = UserInfoModel::where('phone','13880642880')->first();
+        $this->user = Auth::user();
         return $this->user;
     }
 

+ 1 - 0
server/app/Http/Controllers/Api/V1/MyController.php

xqd
@@ -385,6 +385,7 @@ class MyController extends Controller
     public function read()
     {
         $user = $this->getUser();
+//        dd($user);
         $id = $user->id;
         $system_infos = SystemInfoModel::where(function ($query) use($id){
             $query->where('user_id',$id)->where('is_read','0');