| @@ 31-93 (lines=63) @@ | ||
| 28 | use App\DataTables\BaseDataTable; |
|
| 29 | use App\Models\General\Eventlog; |
|
| 30 | ||
| 31 | class EventlogDataTable extends BaseDataTable |
|
| 32 | { |
|
| 33 | /** |
|
| 34 | * Display ajax response. |
|
| 35 | * |
|
| 36 | * @return \Illuminate\Http\JsonResponse |
|
| 37 | */ |
|
| 38 | public function ajax() |
|
| 39 | { |
|
| 40 | return $this->datatables |
|
| 41 | ->eloquent($this->query()) |
|
| 42 | ->editColumn('device.hostname', function($eventlog) { |
|
| 43 | $hostname = is_null($eventlog->device) ? trans('devices.text.deleted') : $eventlog->device->hostname; |
|
| 44 | return '<a href="'.url("devices/".$eventlog->device_id).'">'.$hostname.'</a>'; |
|
| 45 | }) |
|
| 46 | ->make(true); |
|
| 47 | } |
|
| 48 | ||
| 49 | /** |
|
| 50 | * Get the query object to be processed by datatables. |
|
| 51 | * |
|
| 52 | * @return \Illuminate\Database\Query\Builder|\Illuminate\Database\Eloquent\Builder |
|
| 53 | */ |
|
| 54 | public function query() |
|
| 55 | { |
|
| 56 | $eventlogs = Eventlog::with('device')->select('eventlog.*'); |
|
| 57 | return $this->applyScopes($eventlogs); |
|
| 58 | } |
|
| 59 | ||
| 60 | /** |
|
| 61 | * Get columns. |
|
| 62 | * |
|
| 63 | * @return array |
|
| 64 | */ |
|
| 65 | public function getColumns() |
|
| 66 | { |
|
| 67 | return [ |
|
| 68 | 'device.hostname' => [ |
|
| 69 | 'title' => trans('devices.label.hostname'), |
|
| 70 | ], |
|
| 71 | 'type' => [ |
|
| 72 | 'title' => trans('general.text.type'), |
|
| 73 | 'name' => 'eventlog.type', |
|
| 74 | ], |
|
| 75 | 'message' => [ |
|
| 76 | 'title' => trans('general.text.message'), |
|
| 77 | ], |
|
| 78 | 'datetime' => [ |
|
| 79 | 'title' => trans('general.text.timestamp'), |
|
| 80 | ], |
|
| 81 | ]; |
|
| 82 | } |
|
| 83 | ||
| 84 | /** |
|
| 85 | * Get filename for export. |
|
| 86 | * |
|
| 87 | * @return string |
|
| 88 | */ |
|
| 89 | protected function filename() |
|
| 90 | { |
|
| 91 | return 'eventlog'; |
|
| 92 | } |
|
| 93 | } |
|
| 94 | ||
| @@ 31-95 (lines=65) @@ | ||
| 28 | use App\DataTables\BaseDataTable; |
|
| 29 | use App\Models\General\Inventory; |
|
| 30 | ||
| 31 | class InventoryDataTable extends BaseDataTable |
|
| 32 | { |
|
| 33 | /** |
|
| 34 | * Display ajax response. |
|
| 35 | * |
|
| 36 | * @return \Illuminate\Http\JsonResponse |
|
| 37 | */ |
|
| 38 | public function ajax() |
|
| 39 | { |
|
| 40 | return $this->datatables |
|
| 41 | ->eloquent($this->query()) |
|
| 42 | ->editColumn('device.hostname', function($inventory) { |
|
| 43 | $hostname = is_null($inventory->device) ? trans('devices.text.deleted') : $inventory->device->hostname; |
|
| 44 | return '<a href="'.url("devices/".$inventory->device_id).'">'.$hostname.'</a>'; |
|
| 45 | }) |
|
| 46 | ->make(true); |
|
| 47 | } |
|
| 48 | ||
| 49 | /** |
|
| 50 | * Get the query object to be processed by datatables. |
|
| 51 | * |
|
| 52 | * @return \Illuminate\Database\Query\Builder|\Illuminate\Database\Eloquent\Builder |
|
| 53 | */ |
|
| 54 | public function query() |
|
| 55 | { |
|
| 56 | $inventory = Inventory::with('device')->select('entPhysical.*'); |
|
| 57 | return $this->applyScopes($inventory); |
|
| 58 | } |
|
| 59 | ||
| 60 | /** |
|
| 61 | * Get columns. |
|
| 62 | * |
|
| 63 | * @return array |
|
| 64 | */ |
|
| 65 | public function getColumns() |
|
| 66 | { |
|
| 67 | return [ |
|
| 68 | 'device.hostname' => [ |
|
| 69 | 'title' => trans('devices.label.hostname'), |
|
| 70 | ], |
|
| 71 | 'entPhysicalDescr' => [ |
|
| 72 | 'title' => trans('general.text.description'), |
|
| 73 | ], |
|
| 74 | 'entPhysicalName' => [ |
|
| 75 | 'title' => trans('general.text.name'), |
|
| 76 | ], |
|
| 77 | 'entPhysicalModelName' => [ |
|
| 78 | 'title' => trans('general.text.model'), |
|
| 79 | ], |
|
| 80 | 'entPhysicalSerialNum' => [ |
|
| 81 | 'title' => trans('general.text.serial'), |
|
| 82 | ], |
|
| 83 | ]; |
|
| 84 | } |
|
| 85 | ||
| 86 | /** |
|
| 87 | * Get filename for export. |
|
| 88 | * |
|
| 89 | * @return string |
|
| 90 | */ |
|
| 91 | protected function filename() |
|
| 92 | { |
|
| 93 | return 'inventory'; |
|
| 94 | } |
|
| 95 | } |
|
| 96 | ||
| @@ 31-92 (lines=62) @@ | ||
| 28 | use App\DataTables\BaseDataTable; |
|
| 29 | use App\Models\General\Syslog; |
|
| 30 | ||
| 31 | class SyslogDataTable extends BaseDataTable |
|
| 32 | { |
|
| 33 | /** |
|
| 34 | * Display ajax response. |
|
| 35 | * |
|
| 36 | * @return \Illuminate\Http\JsonResponse |
|
| 37 | */ |
|
| 38 | public function ajax() |
|
| 39 | { |
|
| 40 | return $this->datatables |
|
| 41 | ->eloquent($this->query()) |
|
| 42 | ->editColumn('device.hostname', function($syslog) { |
|
| 43 | $hostname = is_null($syslog->device) ? trans('devices.text.deleted') : $syslog->device->hostname; |
|
| 44 | return '<a href="'.url("devices/".$syslog->device_id).'">'.$hostname.'</a>'; |
|
| 45 | }) |
|
| 46 | ->make(true); |
|
| 47 | } |
|
| 48 | ||
| 49 | /** |
|
| 50 | * Get the query object to be processed by datatables. |
|
| 51 | * |
|
| 52 | * @return \Illuminate\Database\Query\Builder|\Illuminate\Database\Eloquent\Builder |
|
| 53 | */ |
|
| 54 | public function query() |
|
| 55 | { |
|
| 56 | $syslog = Syslog::with('device')->select('syslog.*'); |
|
| 57 | return $this->applyScopes($syslog); |
|
| 58 | } |
|
| 59 | ||
| 60 | /** |
|
| 61 | * Get columns. |
|
| 62 | * |
|
| 63 | * @return array |
|
| 64 | */ |
|
| 65 | public function getColumns() |
|
| 66 | { |
|
| 67 | return [ |
|
| 68 | 'device.hostname' => [ |
|
| 69 | 'title' => trans('devices.label.hostname'), |
|
| 70 | ], |
|
| 71 | 'program' => [ |
|
| 72 | 'title' => trans('general.text.program'), |
|
| 73 | ], |
|
| 74 | 'msg' => [ |
|
| 75 | 'title' => trans('general.text.message'), |
|
| 76 | ], |
|
| 77 | 'timestamp' => [ |
|
| 78 | 'title' => trans('general.text.timestamp'), |
|
| 79 | ], |
|
| 80 | ]; |
|
| 81 | } |
|
| 82 | ||
| 83 | /** |
|
| 84 | * Get filename for export. |
|
| 85 | * |
|
| 86 | * @return string |
|
| 87 | */ |
|
| 88 | protected function filename() |
|
| 89 | { |
|
| 90 | return 'syslog'; |
|
| 91 | } |
|
| 92 | } |
|
| 93 | ||