Laravel
SQLSTATE[42S22]: Column not found: 1054 Unknown column 'followers_id ' in 'field list' (SQL: insert into follows
(follow_id
, followers_id
) values (1, 37))
Mysqlにはfollow_id と followers_id columnは存在しているのですが、
上のようなエラーが起きてしまいます。原因がわからず困っています。
ちなみにfollow_id と followers_id columnは元々は別の名前のものを変えたもので、何か関係あれば教えていただきたいです
何卒よろしくお願いします。
Controller
php
1<?php 2 3namespace App\Http\Controllers; 4 5use Illuminate\Http\Request; 6use Auth; 7class FollowsController extends Controller 8{ 9 // 10 public function follow(Request $request) 11 { 12 13 $user_id = Auth::user()->id; 14 // dd($request); 15 $follower_id = $request->input('id'); 16 17 \DB::table('follows') 18 ->insert([ 19 'follow_id' => $follower_id, 20 'followers_id ' => $user_id 21 ]); 22 } 23 public function followList(){ 24 return view('follows.followList'); 25 } 26 public function followerList(){ 27 return view('follows.followerList'); 28 } 29}
View
php
1@extends('layouts.login') 2 3@section('content') 4{{Form::open(['action'=>'UsersController@result'])}} 5{{Form::text('keyword',null,['class' => 'input'])}} 6{{Form::submit('送信',['class' => 'search-button'])}} 7{{Form::close()}} 8 9<div class='container'> 10 <table class='table table-user'> 11 12@foreach ($list as $list) 13 <tr> 14 <td><img src="{{ asset('images/dawn.png')}}"alt = "dawn.png"><td> 15 <td>{{ $list->username }}</td> 16 {{Form::open(['action' => 'FollowsController@follow'])}} 17 {{Form::hidden('id',$list->id)}} 18 <td>{{Form::submit('フォローを解除する',['class'=>'remove-follow'])}}</td> 19 <td>{{Form::submit('フォローをする',['class'=>'follow-user'])}}</td> 20 {{Form::close()}} 21 </tr> 22 @endforeach
Migration File
php
1<?php 2 3use Illuminate\Support\Facades\Schema; 4use Illuminate\Database\Schema\Blueprint; 5use Illuminate\Database\Migrations\Migration; 6 7class CreateFollowsTable extends Migration 8{ 9/** 10* Run the migrations. 11* 12* @return void 13*/ 14public function up() 15{ 16Schema::create('follows', function (Blueprint $table) { 17$table->increments('id')->autoIncrement(); 18$table->integer('follow_id'); 19$table->integer('follower_id'); 20$table->timestamp('created_at')->useCurrent(); 21}); 22} 23 24/** 25* Reverse the migrations. 26* 27* @return void 28*/ 29public function down() 30{ 31Schema::dropIfExists('follows'); 32} 33}
回答1件
あなたの回答
tips
プレビュー