路由:
//用户信息相关
Route::post('api/:version/address$','api/:version.Address/createOrUpdateAddress');
constroller:
//create Or update userAddress
public function createOrUpdateAddress() {
// (new AddressNew())->goCheck();
$validate = new AddressNew();
$validate->goCheck();
// 根据Token来获取uid
// 根据uid来查询用户数据,判断用户是否存在,else throw error
//获取用户从客户端提交来的地址信息
// 根据用户地址信息是否存在从而判断是添加地址or更新地址
$uid = TokenService::getCurrentUID();
$user = UserModel::get($uid);
if (!$user) {
throw new UserException();
}
$dataArray = $validate->getDateByRule(input('post.'));
$userAddress = $user->address;
if (!$userAddress) {
$user->address()->save($dataArray);
}else{
$user->address->save($dataArray); //更新没有括号!
}
return new SuccessMessage();
$token = Request::instance()->header('token');
return $token;
}
于是我新建一个测试controller:
class Test extends Controller
{
public function index()
{
//
$info = Request::instance()->header();
return $info['token'];
}
}
这个是我们这次测试的token 27b61d0911c476f1318a0511723ac641
这个是为什么 神奇我传入部分和胡乱传入都有相应,传入token就没有相应
蛤我传入116f13
已解决,编码问题