我登錄到我的heroku應用程序,這是一個酒店評論應用程序:http://immense-beach-76879.herokuapp.com/。顯然,它不會顯示我在 http://immense-beach-76879.herokuapp.com/reviews 輸入的數(shù)據(jù)。它只是顯示錯誤。它說了一些關于整數(shù)是錯誤的選擇,因為“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 如何協(xié)同工作: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應該保存數(shù)據(jù)并在評論表單下方顯示評論。我所能看到的是表單正在工作,在下面提交數(shù)據(jù),但它沒有顯示任何達達...
1 回答

BIG陽
TA貢獻1859條經(jīng)驗 獲得超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 關注
- 337 瀏覽
添加回答
舉報
0/150
提交
取消