SQLSTATE [42S22]:找不到列:

时间:2017-10-18 16:29:07

标签: laravel laravel-5.4

我收到此错误未知列city = Faislabad但我的数据库中有此列。我想获取城市是faislabad的数据。

我的控制器的代码是

       public function chart(Request $request)
        {
             $users = Disease::where("city=$request->city")

                ->get();

    $chart = Charts::database($users, 'bar', 'highcharts')

              ->title("Monthly new Register Users")

              ->elementLabel("Total Users")

              ->dimensions(1000, 500)

              ->responsive(false)

              ->groupBy('name');

    return view('test1',compact('chart'));  
        }

我桌子的迁移是

   public function up()
{
    Schema::create('diseases', function (Blueprint $table) {
        $table->increments('id');
        $table->string('name');
        $table->string('city');
        $table->string('symptomps');
    });
}

请告诉我这件事我做错了什么。

1 个答案:

答案 0 :(得分:2)

变化:

$users = Disease::where("city=$request->city")->get();

$users = Disease::where('city', $request->city)->get();