编辑用户信息

admin2年前Laravel684

*/
public function useredit()
{

   $avatar = request()->input('avatar');
   $nickname = request()->input('nickname', 1);
   $sex = request()->input('sex');
   $birthday = request()->input('birthday');
   $field = request()->input('filed');
   $class = request()->input('class');
   $type = request()->input('type');

   if (!$field) {
       return $this->error('请输入学段');
   }
   if (!$class) {
       return $this->error('请输入年级');
   }
   if (!$type) {
       return $this->error('请输入类型');
   }

   $data = [];
   if ($avatar) {
       $avatar = str_replace($this->domain(), '', $avatar);
       $data['avatar'] = $avatar;
   }
   if ($nickname) {
       $data['nickname'] = $nickname;
   }
   if ($sex) {
       $data['sex'] = $sex;
   }
   if ($birthday) {
       $data['birthday'] = $birthday;
   }
   if ($field) {
       $data['filed'] = $field;
   }
   if ($class) {
       $data['class'] = $class;
   }
   if ($type) {
       $data['type'] = $type;
   }
   if ($data) {
       $info = Db::table('member')->where(array('id' => $this->user_id))->update($data);
       if ($info !== false) {
           return $this->success('修改成功');
       } else {
           return $this->error('修改失败');
       }
   } else {
       return $this->error('无修改数据');
   }
}

返回列表

上一篇:修改密码

下一篇:上传图片

相关文章

公众号登录

public function wxlogin(){       $code = request()->input('code'); &n...

php 优化

使用 gc_collect_cycles() 强制进行垃圾回收 PHP 的垃圾回收机制会自动释放不再使用的变量所占用的内存。然而,在某些情况下,尤其是在长时间运行的脚本(如 CLI...

发送公众号信息

* 发送消息 */public function tosend($openid, $title, $content, $time, $aid){    $tokens = $thi...

腾讯云发送短信

<?phpnamespace App\Http\Controllers;use Illuminate\Http\Request;use Illuminate\Support\Facades\DB...

忘记密码

publicfunction forget(){    $phone = request()->input('phone');    $c...

抖音小程序登录

$code = request()->input('code');$nickname = request()->input('nickName');$ava...