我登录到我的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<?phpuse 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应该保存数据并在评论表单下方显示评论。我所能看到的是表单正在工作,在下面提交数据,但它没有显示任何达达...
1 回答

BIG阳
TA贡献1859条经验 获得超6个赞
您可以在您的方法中更改此行(17)index
App\Http\Controllers\ReviewController
$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');
- 1 回答
- 0 关注
- 322 浏览
添加回答
举报
0/150
提交
取消