public function getRecordCount($id = NULL){
if ($id == 0) {
$count = $this->leftJoin('liip_user_customers', 'warehouse_to', '=', 'liip_user_customers.customer_id')
->where('status', '=', $id)
->where('created_by_id', '=', Auth::user()->id)
->select('id')
->count('id');
if (!empty($count)) {
return $count;
}else{
return 0;
}
}
}
Это на моем контроллере.
public function getIndex(){
$count_approval = $this->warehouse_transfer->getRecordCount(0);
$count_correction = $this->warehouse_transfer->getRecordCount(14);
$count_final = $this->warehouse_transfer->getRecordCount(13);
$count_pending = $this->warehouse_transfer->getRecordCount(15);
// Title
$title = Lang::get('liipWarehousePalletTransfer::warehousePalletTransfer/title.warehouse_pallet_transfers_management');
// Show the page
return View::make('liipWarehousePalletTransfer::index', compact( 'title', 'count_approval', 'count_correction', 'count_close', 'count_disapprove', 'count_final', 'count_pending'));
}
И я получил некоторую ошибку:
SQLSTATE[23000]: Integrity constraint violation: 1052 Column 'id'
in field list is ambiguous (SQL: select count('id') as aggregate from
'liip_warehouse_pallet_transfers' left join 'liip_user_customers' on
'warehouse_to' = 'liip_user_customers'.'customer_id' where 'status' = 0
and 'created_by_id' = 159)
Проверьте прикрепленное изображение
Значок на вкладке "Для утверждения" должен быть "5". Я уже искал эту проблему, но я не могу найти такой же сценарий, как мой.
$this->leftJoin('liip_user_customers',
'warehouse_to', '=', 'liip_user_customers.customer_id')
Ошибка возникает из-за отсутствия имени таблицы в вашем левом соединении TABLE_NAME.warehouse_to
См. Laravel Join для получения дополнительной информации
warehouse_to.COLUMN