SQLSTATE[22P02]:无效的文本表示形式:7 错误:整数的输入语法无效



我登录了我的heroku应用程序,这是一个酒店评论应用程序:http://immense-beach-76879.herokuapp.com/。显然,它不会显示我在 http://immense-beach-76879.herokuapp.com/reviews 输入的数据。它只是显示错误。它说了一些关于整数是错误选择的东西,因为"kiki"应该是一个字符串,对吗?如果你需要看我的代码,这里是:https://github.com/kikidesignnet/hotelreviews。

这是我的错误:

SQLSTATE[22P02]: Invalid text representation: 7 ERROR: invalid input syntax for integer: "kiki" (SQL: select * from "reviews" where "user_id" in (1, kiki, k@k.com, ?, 2020-02-07 05:57:47, 2020-02-07 05:57:47) order by "created_at" desc limit 20)

我一直在学习本教程来了解 Laravel 以及 React/Laravel 如何协同工作: https://kaloraat.com/articles/laravel-react-crud-tutorial 和他们的 github repo:https://github.com/kaloraat/laravel-react-crud

这是我的迁移create_reviews_table.php

<?php
use IlluminateDatabaseMigrationsMigration;
use IlluminateDatabaseSchemaBlueprint;
use IlluminateSupportFacadesSchema;
class CreateReviewsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('reviews', function (Blueprint $table) {
$table->increments('id');
$table->integer('user_id')->unsigned()->index();
$table->string('name');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('reviews');
}
}

如您所见,此应用程序应该注册一个新用户。然后,当用户登录并提交酒店评论时,reviews.api 应该将数据保存在评论表单下方并显示评论。

我所能看到的是表单正在工作,提交下面的数据,但它没有显示任何 dada......

您可以在index方法中更改此行(17(AppHttpControllersReviewController

$allReviews = $review->whereIn('user_id', $request->user())->with('user');

$allReviews = $review->where('user_id', $request->user()->id)->with('user');

$allReviews = $review->where('user_id', Auth::id())->with('user');

最新更新