查询时,我想使用store_id而不是nd_001_store_id。我收到如下错误 : Production.ERROR: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'store_id' in 'where Clause'
$user_store_id = Session::get('user_store_id'); //for example 6
$a = "2020-06-20 13:00:00";
$b = "2020-07-05 13:00:00";
$sales_types = ['retail', 'wholesale'];
$invoice_items_stock_ids = InvoiceItems::select(
'nd_001_stock_id AS stock_id',
'nd_000_store_id AS store_id',
DB::raw("CONCAT(add_date_store, ' ', add_hours_store) AS date_range")
)->where(function ($query) use ($user_store_id) {
$query->where('store_id', '=', $user_store_id);
})->orWhere(function ($query) use ($a, $b) {
$query->where('date_range', '>=', $a)
->where('date_range', '<=', $b);
})
->whereIn('type', $sales_types)->get();
date_range 和 store_id 未找到列错误
谢谢,最诚挚的问候
扬帆大鱼