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)

我一直在学习本教程,以了解拉拉维尔以及 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 Illuminate\Database\Migrations\Migration;

use Illuminate\Database\Schema\Blueprint;

use Illuminate\Support\Facades\Schema;


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应该保存数据并在评论表单下方显示评论。


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


繁花不似锦
浏览 294回答 1
1回答

BIG阳

您可以在您的方法中更改此行(17)indexApp\Http\Controllers\ReviewController$allReviews&nbsp;=&nbsp;$review->whereIn('user_id',&nbsp;$request->user())->with('user');自$allReviews&nbsp;=&nbsp;$review->where('user_id',&nbsp;$request->user()->id)->with('user');或$allReviews&nbsp;=&nbsp;$review->where('user_id',&nbsp;\Auth::id())->with('user');
打开App,查看更多内容
随时随地看视频慕课网APP