when querying, I wanted to use store_id instead of nd_001_store_id. I get the error as below 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 and store_id Column not found error
Thanks, Best Regards
store_id
column. You should be able to query thend_000_store_id
directly.->where('nd_000_store_id', $user_store_id)
. – LLai