hello @johnny
i have set relation with where in clause but showing error
if i set relation like this
$crud->setRelation(‘user_id’, ‘presensi_emp’, ‘nama’,“user_id in (‘152’,‘69’)”);
this will showing error
PDOException: SQLSTATE[23000]: Integrity constraint violation: 1052 Column 'user_id' in where clause is ambiguous in file D:\laragon8\www\siintan\vendor\laminas\laminas-db\src\Adapter\Driver\Pdo\Connection.php on line 376
then i change my relation with this script
$crud->setRelation(‘user_id’, ‘presensi_emp’, ‘nama’,“presensi_emp.user_id in (‘152’,‘69’)”);
but still showing error with other message
PDOException: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'presensi_emp.user_id' in 'where clause' in file D:\laragon8\www\siintan\vendor\laminas\laminas-db\src\Adapter\Driver\Pdo\Connection.php on line 376
this is my complete controller
public function validasi_kinerja_utama_harian($extra)
{
$crud = $this->general->_getGroceryCrudEnterprise();
$crud->setTable(‘sdm_tr_kinerja’);
$crud->where(['status_validasi not like ? ’ => ‘%Valid%’]);
$crud->setSubject(‘Kinerja Utama Harian’, ‘Kinerja Utama Harian’);
$crud->columns([‘user_id’,‘kinerja_id’, ‘tanggal’, ‘bukti_kuantitas’, ‘bukti_kualitas’, ‘status’, ‘nilai_kuantitas’, ‘status_validasi’]);
$crud->displayAs([‘kinerja_id’ => ‘Rencana Kinerja’, ‘nilai_kuantitas’ => ‘Nilai’,‘user_id’=>‘Pegawai’]);
$crud->setRelation(‘user_id’, ‘presensi_emp’, ‘nama’,“presensi_emp.user_id in (‘152’,‘69’)”);
$crud->setRelation(‘kinerja_id’, ‘sdm_mst_kinerja’, ‘rencana_kinerja’, [‘tahun’ => date(‘Y’), ‘jenis’ => ‘Utama’]);
$crud->editFields([‘kinerja_id’, ‘tanggal’, ‘bukti_kuantitas’, ‘bukti_kualitas’, ‘status’, ‘nilai_kuantitas’, ‘komentar_validator’]);
$crud->where(“sdm_tr_kinerja.user_id in (‘152’,‘69’)”);
$crud->unsetAdd();
$crud->unsetDelete();
$crud->callbackAddField(‘tanggal’, function ($fieldType, $fieldName) {
return ‘’;
});
$crud->callbackEditField(‘tanggal’, function ($fieldValue, $primaryKeyValue, $rowData) {
return ‘’;
});
$crud->defaultOrdering(‘sdm_tr_kinerja.id’, ‘desc’);
$crud->fieldType(‘tanggal’, ‘string’);
$crud->defaultOrdering(‘tanggal’,‘desc’);
$crud->requiredFields([‘kinerja_id’, ‘status’, ‘bukti_kualitas’]);
$crud->setFieldUploadMultiple(‘bukti_kuantitas’, ‘assets/uploads/kinerja’, ‘/assets/uploads/kinerja/’);
$output = $crud->render();
return $this->general->_showOutput($output, null, @$extra);
}
regards
Nasrul