/** * Remove the specified device from storage. * * @param int $id * @return Response */ public function destroy($id) { $kinddevices = KindDevice::find($id); if ($kinddevices != null) { $kinddevices->delete(); } return json_encode("success"); }
/** * Export to excel list device * * @return file excel */ public function exportExcel() { Excel::create('List Device', function ($excel) { $excel->sheet('Sheetname', function ($sheet) { $sheet->setBorder('A1:K1', 'thin'); $sheet->cells('A1:K1', function ($cells) { $cells->setBackground('blue'); $cells->setFontColor('#FFFFFF'); $cells->setAlignment('center'); $cells->setValignment('middle'); $cells->setFontFamily('Times New Roman'); }); $sheet->setFontFamily('Times New Roman'); $sheet->setWidth(array('A' => '10', 'B' => '20', 'C' => '20', 'D' => '20', 'E' => '20', 'F' => '20', 'G' => '40', 'H' => '20', 'I' => '30', 'J' => '20', 'K' => '20')); $data = []; /*HEADER EXCEL*/ array_push($data, array('STT', 'NAME DEVICE', 'SERIAL DEVICE', 'RECEIVE DATE', 'STATUS')); /*CONTENT EXCEL*/ $device = Device::all(); $number = 0; foreach ($device as $key => $value) { $device[$key]->device_name = KindDevice::find($value->kind_device_id)->device_name; $device[$key]->status = StatusDevice::find($value->status_id)->status; $device[$key]->employee_code = Employee::find($value->employee_id)->employee_code; $number++; array_push($data, array($number, $value->device_name, $value->serial_device, $value->receive_date, $value->status, $value->distribution)); } $sheet->fromArray($data, null, 'A1', false, false); }); })->download('xls'); }