xiaogang 4 年 前
コミット
158cfe5c31

+ 4 - 3
app/Http/Controllers/Api/AuthorizationsController.php

xqd xqd
@@ -147,7 +147,10 @@ class AuthorizationsController extends Controller
         if(User::where(['mobile'=>$request->mobile])->first()){
             return $this->response->errorForbidden("该手机号码已使用");
         }
+
         $ins = array();
+
+        //邀请码设置
         if(isset($request->ycode) && $request->ycode!=""){
             if(!$puser = User::where(['ycode'=>$request->ycode])->first()){
                 return $this->response->errorForbidden("邀请码不存在");
@@ -155,14 +158,12 @@ class AuthorizationsController extends Controller
             $ins['pid'] = $puser->id;
         }
         $ins['mobile'] = $request->mobile;
-        $ins['password'] = $request->password;//
-        $ins['ycode'] = $this->createCode();
+        $ins['password'] = $request->password;
         if(User::create($ins)){
             return response()->json(['message'=>"注册成功"])->setStatusCode(201);
         }else{
             return $this->response->errorForbidden("注册失败");
         }
-
     }
 
 

+ 14 - 0
app/Http/Controllers/Api/UserController.php

xqd
@@ -0,0 +1,14 @@
+<?php
+
+
+namespace App\Http\Controllers\Api;
+class UserController extends Controller
+{
+    /**
+     * 选择性别
+     */
+    public function checksex(){
+        $user = auth('api')->user();
+        dd($user);
+    }
+}

+ 12 - 0
routes/api.php

xqd
@@ -49,6 +49,18 @@ $api->version('v1', [
     });
     //需要 token 验证的接口
     $api->group(['middleware' => 'api.auth'], function ($api) {
+        /*
+        |--------------------------------------------------------------
+        |  用户信息相关
+        |--------------------------------------------------------------
+        */
+        $api->group(['prefix' => 'user'], function ($api) {
+            //设置性别
+            $api->post('/checksex', 'UserController@checksex')->name('user.checksex');
+
+        });
+
+
         /*
         |--------------------------------------------------------------
         |  退出登录