first(); if(!$user){ return false; } if(!password_verify($password,$user->password)){ return false; } return $user->toArray(); } /** * 账号注册逻辑 * * @param array $data 用户数据 * @return bool */ public function register(array $data) { try { $data['password'] = create_password($data['password']); $data['created_at'] = date('Y-m-d H:i:s'); $result = User::create($data); // 创建用户的默认笔记分类 ArticleClass::create([ 'user_id' => $result->id, 'class_name' => '我的笔记', 'is_default' => 1, 'sort' => 1, 'created_at' => time() ]); } catch (\Exception $e) { $result = false; } return $result ? true : false; } }