コード例 #1
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     $informationdevices = InformationDevice::find($id);
     if ($informationdevices != null) {
         $informationdevices->delete();
     }
     return json_encode("success");
 }
コード例 #2
0
 /**
  * Export list overview device to excel
  * @return void
  */
 public function exportExcel()
 {
     Excel::create('List Device', function ($excel) {
         $excel->sheet('Sheetname', function ($sheet) {
             //$sheet->mergeCells('A1:C1');
             $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', 'DISTRIBUTION'));
             /*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]->distribution = InformationDevice::find($value->information_id)->distribution;
                 $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');
 }