import 'package:myapp/core/routes/router.gr.dart' as app_router;
child: MaterialApp(
title: 'MyApp',
debugShowCheckedModeBanner: false,
builder: ExtendedNavigator.builder<app_router.Router>(
router: app_router.Router()
),
Run Code Online (Sandbox Code Playgroud)
我已经实现了自动路由,但是我在这里收到一个错误,即 getter 键被调用为 null
public function create(Request $request){
$comment = new Comment;
$comment->user_id = Auth::user()->id;
$comment->post_id = $request->id; //here is where the response is string
$comment->comment = $request->comment;
$comment->save();
$comment->user;
return response()->json(
$comment,
);
}
Run Code Online (Sandbox Code Playgroud)
我不知道为什么响应是字符串 id 并且在数据库迁移中 post_id 表$table->unsignedBigInteger('post_id');是否应该是整数..
{
"user_id": 4,
"post_id": "2", //response is string
"comment": "test string id finale",
"updated_at": "2020-10-31T19:55:49.000000Z",
"created_at": "2020-10-31T19:55:49.000000Z",
"id": 11,
}
Run Code Online (Sandbox Code Playgroud)