我有產品型號和它的擁有搜索瓢 ,這是在查詢 代碼3 orwhere和一個地方laravel 5.3
public static function searchScoop($keyword)
{
if(!Auth::check())
{
$data = Item::limit(30)->where('item_id','like','%'.$keyword.'%')->
orwhere('item_name','like','%'.$keyword.'%')->
get(['id','item_id','item_name','item_price','item_total','item_color','item_main_category','item_sub_category','item_sub_sub_category','item_q_in_c','item_last_in','item_total_in','item_inserter','item_state','item_admin','item_area','item_row','item_location','created_at','updated_at','deleted_at']);
}
else
{
$data = Item::limit(30)->withTrashed()->where('item_id','like','%'.$keyword.'%')->
orwhere('item_name','like','%'.$keyword.'%')->
orwhere('item_note','like','%'.$keyword.'%')->
orwhere('item_barcode','=',$keyword)->
get(['id','item_id','item_name','item_price','item_total','item_color','item_main_category','item_sub_category','item_sub_sub_category','item_q_in_c','item_last_in','item_total_in','item_inserter','item_state','item_admin','item_area','item_row','item_location','created_at','updated_at','deleted_at']);
}
return $data;
}
和IM試圖讓和statment,所以我加入這個
else
{
$data = Item::limit(30)->withTrashed()->
where('item_area','<>',2)->
where('item_id','like','%'.$keyword.'%')->
orwhere('item_name','like','%'.$keyword.'%')->
orwhere('item_note','like','%'.$keyword.'%')->
orwhere('item_barcode','=',$keyword)->
get(['id','item_id','item_name','item_price','item_total','item_color','item_main_category','item_sub_category','item_sub_sub_category','item_q_in_c','item_last_in','item_total_in','item_inserter','item_state','item_admin','item_area','item_row','item_location','created_at','updated_at','deleted_at']);
}
return $data;
而且dosnot工作 我還是從區域2 騎上項目,這是查詢時我改變得到toSql
select * from `items` where `item_area` <> ? and `item_id` like ? or `item_name` like ? or `item_note` like ? or `item_barcode` = ? limit 30
任何幫助,請
嘗試'這裏( '!=' 'item_area',2)' –
感謝米拉罐仍然是相同的 –