php - 无法将数据存储到 laravel 用户模型中
问题描述
我正在尝试通过 API 请求为用户模型创建一个 crud,我已经使用 sanctum 和 UI 脚手架进行了身份验证
这是我的 api.php 文件中的路线
Route::post('/customer', function() {
request()->validate([
'name' => 'required',
'email' => 'required',
'password' => 'required',
]);
return User::create([
'name' => request('name'),
'email' => request('email'),
'password' => request('password'),
]);
});
但是当我通过请求时
POST http://localhost:8000/api/customer HTTP/1.1
Content-Type: application/json
{
"name" : "xxx",
"email": "xx@gmail.com",
"password": "wqaxszcde"
}
它返回 419 未知状态
解决方案
推荐阅读
- python - 尝试在 python 版本 3.6.4 中安装 sklearn lib 时出错
- java - 导入 spring-aspects 后,找不到某些控制器
- python - 理解字典和字典结构
- java - Jackson:嵌套对象映射实现
- mysql - 如何在条件下将 varchar 字符串传递给存储过程?
- d3.js - 多折线图 d3 v4 的工具提示
- android - PhilJay/MPAndroidChart 条形图中的值重叠问题
- java - Retrofit2 GsonConverter 预期为 BEGIN_OBJECT,但在第 1 行第 2 列路径 $ 处为 BEGIN_ARRAY
- python - 为什么熊猫显示“?” 而不是 NaN
- css - Can't get to load css styles in angular unit testing using jasmine karma