this is my code :
public function index()
{
$crud = $this->_getGroceryCrudEnterprise();
$crud->setTable('kal_invoices');
$crud->setUniqueId('kal_invoices');
$crud->unsetCssTheme();
$crud->unsetExport();
$crud->unsetPrint();
//$crud->where(['per_info_personal.id_payroll >= ?' => 0]);
$crud->setSubject('Invoices', 'Daftar Invoices');
$crud->columns(['fk_id_projects', 'nama', 'nomor', 'tanggal', 'id_invoice']);
$crud->addFields(['fk_id_projects', 'nama', 'nomor', 'tanggal', 'status', 'id_invoice', 'inserted_by', 'inserted_time']);
$crud->editFields(['fk_id_projects', 'nama', 'nomor', 'tanggal', 'status', 'updated_by', 'updated_time']);
$crud->fieldType('status', 'dropdown_search', [
'Menunggu' => 'Menunggu',
'Lunas' => 'Lunas',
'Dibatalkan' => 'Dibatalkan'
]);
$crud->displayAs('fk_id_projects', 'Nama Project');
$crud->fieldType('inserted_by', 'hidden');
$crud->fieldType('inserted_time', 'hidden');
$crud->fieldType('id_invoice', 'hidden');
$crud->fieldType('updated_by', 'hidden');
$crud->fieldType('updated_time', 'hidden');
$crud->setRelation('fk_id_projects', 'kal_kegiatan', 'nama_kegiatan');
$crud->setMasterDetail(url('invoice/details'));
$crud->setActionButton('Kirim', 'fa fa-envelope', function ($row) {
return url('invoice/kirim/' . $row->id.'/'.$row->id_invoice);
}, false);
$crud->setActionButton('Cetak', 'fa fa-print', function ($row) {
return url('invoice/cetak/' . $row->id.'/'.$row->id_invoice);
}, false);
//Crypt::encryptString($row->id)
$crud->callbackAddForm(function ($data) {
$data['id_invoice'] = strtotime(date('Y-m-d H:i:s'));
$data['inserted_by'] = Auth::user()->id;
$data['inserted_time'] = date('Y-m-d H:i:s');
return $data;
});
$crud->callbackEditForm(function ($data) {
$data['updated_by'] = Auth::user()->id;
$data['updated_time'] = date('Y-m-d H:i:s');
return $data;
});
$crud->setCsrfTokenName('_token');
$crud->setCsrfTokenValue(csrf_token());
$output = $crud->render();
$output->detail = 'N';
return $this->_showOutput($output);
}
public function details()
{
$crud = $this->_getGroceryCrudEnterprise();
$crud->setTable('kal_invoices_detail');
$crud->setUniqueId('kal_invoices_detail');
$crud->unsetDatagridTitle();
$crud->unsetTools();
$crud->unsetSearchColumns(['nama', 'jumlah', 'harga']);
$crud->columns(['nama', 'jumlah', 'harga']);
$crud->addFields(['fk_id_invoices', 'nama', 'jumlah', 'harga', 'inserted_by', 'inserted_time']);
$crud->editFields(['fk_id_invoices', 'nama', 'jumlah', 'harga', 'updated_by', 'updated_time']);
if (!empty($_POST['master_id'])) {
if (is_numeric($_POST['master_id'])) {
session(['master_id' => $_POST['master_id']]);
$crud->where(['fk_id_invoices' => $_POST['master_id']]);
} else {
throw new InvalidArgumentException("Invalid argument for the field 'master_id'");
}
}
$crud->fieldType('inserted_by', 'hidden');
$crud->fieldType('inserted_time', 'hidden');
$crud->fieldType('updated_by', 'hidden');
$crud->fieldType('updated_time', 'hidden');
$crud->fieldType('fk_id_invoices', 'hidden');
$crud->callbackAddField('harga', function ($fieldType, $fieldName) {
return '<input type="text" name ="harga" class = "form-control decimal">';
});
$crud->callbackAddField('harga', function ($fieldType, $fieldName) {
return '<input type="text" name ="harga" class = "form-control decimal">';
});
$crud->callbackAddForm(function ($data) {
$data['fk_id_invoices'] = session('master_id');
$data['inserted_by'] = Auth::user()->id;
$data['inserted_time'] = date('Y-m-d H:i:s');
return $data;
});
$crud->callbackEditForm(function ($data) {
$data['fk_id_invoices'] = session('master_id');
$data['updated_by'] = Auth::user()->id;
$data['updated_time'] = date('Y-m-d H:i:s');
return $data;
});
$crud->setCsrfTokenName('_token');
$crud->setCsrfTokenValue(csrf_token());
$output = $crud->render();
return $this->_showOutput_detail($output);
}
Have you try reproduce this error @nasrul ?