【发布时间】:2020-11-23 05:16:23
【问题描述】:
我的控制器代码是
$data = DB::table('ride')
->leftJoin('driver','ride.driver_id','=','driver.id')
->select([
DB::raw('driver.name as driver_name'),
DB::raw('monthname(ride.created_at) as month'),
DB::raw('year(ride.created_at) as year'),
])
->where("driver.users_id", $users_id)
->groupBy(['year', 'month','driver_id'])
->get()
->toArray();
但它显示违反完整性约束:1052 列“created_at”在 where 子句中是不明确的,尽管我已经提到了“ride.created_at”
型号
protected $table = "ride";
public $timestamps = false;
protected $fillable =[
'status',
'driver_id',
];
【问题讨论】:
-
您的骑行模型是什么样的?你能展示它的迁移吗?
-
检查更新的问题
-
@afra-janjua 我认为显示迁移文件而不是模型会更好。
-
好的,我添加了迁移和模型
标签: laravel