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,
);
}
I dont know why the reponse is string id and in the database migration the post_id table is $table->unsignedBigInteger('post_id'); it suppose to be integer..
{
"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,
}
(int). All values in request are strings.