I have conditional data and it ignores that conditions while returning data:
Works fine
$orders = Order::where('user_id', $user->id)->with(['customer', 'laundry', 'driver', 'driver.user', 'progresses' => function($p){ $p->orderby('created_at', 'asc'); }, 'progresses.progress', 'services'])->get(); Return wrong data
$orders = Order::where('user_id', $user->id)->with(['customer', 'laundry', 'driver', 'driver.user', 'progresses' => function($p){ $p->orderby('created_at', 'asc'); }, 'progresses.progress', 'services']) ->where('id', 'like', '%'.$this->search.'%') ->orWhere('transport', 'like', '%'.$this->search.'%') ->orWhere('amount', 'like', '%'.$this->search.'%') ->orWhere('weight', 'like', '%'.$this->search.'%') ->orWhere('total', 'like', '%'.$this->search.'%') ->paginate(10); Issue
The second query return all orders and ignores where('user_id', '=', $user->id).
Question
- why it ignore
where('user_id', '=', $user->id) - How to fix it?
没有评论:
发表评论