4
Laravel Advanced Wheres làm thế nào để truyền biến vào hàm?
Ví dụ trong doc: DB::table('users') ->whereExists(function($query) { $query->select(DB::raw(1)) ->from('orders') ->whereRaw('orders.user_id = users.id'); }) ->get(); Nhưng điều gì sẽ xảy ra nếu tôi cần sử dụng biến bên ngoài như vậy: ->where('city_id', '=', $this->city->id) ->where(function($query) { $query->where('name', 'LIKE', '%'.$searchQuery.'%') ->orWhere('address', 'LIKE', '%'.$searchQuery.'%') }) Hiện tại, tôi đã tạo thuộc tính mới …