diff --git a/app/Http/Controllers/Manager/AuthController.php b/app/Http/Controllers/Manager/AuthController.php index b551876..efc578d 100644 --- a/app/Http/Controllers/Manager/AuthController.php +++ b/app/Http/Controllers/Manager/AuthController.php @@ -174,6 +174,40 @@ class AuthController extends Controller return response()->json($manager->toArray()); } + /** + * @OA\Post( + * path="/manager/update", + * summary="V2-登录者个人信息修改", + * @OA\Parameter(name="token", in="query", @OA\Schema(type="string"), required=true, description="token"), + * @OA\Parameter(name="name", in="query", @OA\Schema(type="string"), required=false, description="姓名"), + * @OA\Parameter(name="sex", in="query", @OA\Schema(type="string"), required=false, description="性别:[男,女]"), + * @OA\Parameter(name="password", in="query", @OA\Schema(type="string"), required=false, description="密码"), + * @OA\Parameter(name="openid", in="query", @OA\Schema(type="string"), required=false, description="微信openid"), + * @OA\Parameter(name="unionid", in="query", @OA\Schema(type="string"), required=false, description="微信unionid"), + * @OA\Parameter(name="mobile", in="query", @OA\Schema(type="string"), required=false, description="手机号码"), + * @OA\Parameter(name="birthday", in="query", @OA\Schema(type="string"), required=false, description="生日"), + * @OA\Parameter(name="avatar", in="query", @OA\Schema(type="string"), required=false, description="头像访问路径(相对于根目录的绝对路径)"), + * description="", + * @OA\Response( + * response="200", + * description="登录者个人信息修改" + * ) + * ) + */ + public function update() + { + $manager = $this->guard()->user(); + $fillable = (new Manager())->getFillable(); + $update = []; + foreach (request()->all() as $k => $v) { + if (in_array($k,$fillable)) { + $update[$k] = $v; + } + } + $manager->update($update); + return response()->json($manager->toArray()); + } + /** * @OA\Post( * path="/manager/logout", diff --git a/app/Manager.php b/app/Manager.php index c6be8c3..a321153 100644 --- a/app/Manager.php +++ b/app/Manager.php @@ -56,7 +56,7 @@ class Manager extends Authenticatable implements JWTSubject use Notifiable; CONST GUARD_NAME = "manager"; - public $appends = ["type_name","avatar_url"]; + public $appends = ["type_name", "avatar_url"]; public function getAvatarUrlAttribute() { @@ -121,7 +121,7 @@ class Manager extends Authenticatable implements JWTSubject * @var array */ protected $fillable = [ - 'type', 'name', 'sex', 'username', 'password', 'openid', 'unionid', 'mobile', 'birthday' + 'type', 'name', 'sex', 'username', 'password', 'openid', 'unionid', 'mobile', 'birthday', 'avatar' ]; /** diff --git a/routes/web.php b/routes/web.php index e7dc539..88b16b9 100644 --- a/routes/web.php +++ b/routes/web.php @@ -128,6 +128,9 @@ Route::group(["namespace" => "Manager", "prefix" => "manager"], function () { Route::get('get-video/{id}', 'TrainingController@getVideo'); Route::group(['middleware' => ['authorize.jwt:manager']], function () { + Route::post('me', 'AuthController@me'); + Route::post('update', 'AuthController@update'); + Route::post('create-paramedic', 'ParamedicController@createParamedic'); Route::post('update-paramedic/{id}', 'ParamedicController@updateParamedic'); Route::post('delete-paramedic/{id}', 'ParamedicController@deleteParamedic'); @@ -136,7 +139,6 @@ Route::group(["namespace" => "Manager", "prefix" => "manager"], function () { Route::get('get-project-paramedics/{project_id}', 'ParamedicController@getProjectParamedics'); Route::get('get-paramedic/{id}', 'ParamedicController@getParamedic'); - Route::post('me', 'AuthController@me'); Route::get('get-projects', 'OrdersController@getProjects'); Route::get('get-notifications', 'AuthController@getNotifications'); Route::get('get-notification/{id}', 'AuthController@getNotification');