我收到此错误未知列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');
});
}
请告诉我这件事我做错了什么。
答案 0 :(得分:2)
变化:
$users = Disease::where("city=$request->city")->get();
到
$users = Disease::where('city', $request->city)->get();