Following is my eloquent query
$orders = Order::with('assignedVendor','currentStatus','hasOrders.hasSubService.hasMainService.hasCategory','hasCustomer.hasCompany.hasPincode','hasCustomer.hasPincode')
->whereHas('hasCustomer.hasCompany.hasPincode', function ($query) use ($key) {
$query->where('cityId',$key);
})
->WhereHas('hasCustomer.hasPincode', function ($query) use ($key) {
$query->where('cityId',$key);
})
->get();
I have also tried
$orders = Order::with('assignedVendor','currentStatus','hasOrders.hasSubService.hasMainService.hasCategory')
->whereHas('hasCustomer.hasCompany.hasPincode', function ($query) use ($key) {
$query->where('cityId',$key);
})
->WhereHas('hasCustomer.hasPincode', function ($query) use ($key) {
$query->where('cityId',$key);
})
->get();
I have also tried
$orders = Order::with('assignedVendor','currentStatus','hasOrders.hasSubService.hasMainService.hasCategory','hasCustomer.hasCompany.hasPincode','hasCustomer.hasPincode')
->whereHas('hasCustomer.hasCompany.hasPincode', function ($query) use ($key) {
$query->where('cityId',$key);
})
->WhereHas('hasCustomer.hasPincode', function ($query) use ($key) {
$query->where('cityId',$key);
})
->get();
after googling around i found some repos on github with this as a bug i am not sure in my case if this is a bug or my query is wrong. I am new to laravel. I can achieve this using query builder but i want to use eloquent. I want to retrieve all the orders which are connected to pincode table through hasCustomer.hasPincode and hasCustomer.hasCompany.hasPincode. I am using laravel 5.6 and i have used such queries in 5.5 and they worked.
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire