| @@ 31-121 (lines=91) @@ | ||
| 28 | use App\Models\General\Eventlog; |
|
| 29 | use Yajra\Datatables\Services\DataTable; |
|
| 30 | ||
| 31 | class EventlogDataTable extends DataTable |
|
| 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 | return '<a href="'.url("devices/".$eventlog->device->device_id).'">'.$eventlog->device->hostname.'</a>'; |
|
| 44 | }) |
|
| 45 | ->make(true); |
|
| 46 | } |
|
| 47 | ||
| 48 | /** |
|
| 49 | * Get the query object to be processed by datatables. |
|
| 50 | * |
|
| 51 | * @return \Illuminate\Database\Query\Builder|\Illuminate\Database\Eloquent\Builder |
|
| 52 | */ |
|
| 53 | public function query() |
|
| 54 | { |
|
| 55 | $eventlogs = Eventlog::with('device')->select('eventlog.*'); |
|
| 56 | return $this->applyScopes($eventlogs); |
|
| 57 | } |
|
| 58 | ||
| 59 | /** |
|
| 60 | * Optional method if you want to use html builder. |
|
| 61 | * |
|
| 62 | * @return \Yajra\Datatables\Html\Builder |
|
| 63 | */ |
|
| 64 | public function html() |
|
| 65 | { |
|
| 66 | return $this->builder() |
|
| 67 | ->columns($this->getColumns()) |
|
| 68 | ->parameters($this->getBuilderParameters()); |
|
| 69 | } |
|
| 70 | ||
| 71 | /** |
|
| 72 | * Get columns. |
|
| 73 | * |
|
| 74 | * @return array |
|
| 75 | */ |
|
| 76 | private function getColumns() |
|
| 77 | { |
|
| 78 | return [ |
|
| 79 | 'device.hostname' => [ |
|
| 80 | 'title' => trans('devices.label.hostname'), |
|
| 81 | ], |
|
| 82 | 'type' => [ |
|
| 83 | 'title' => trans('general.text.type'), |
|
| 84 | 'name' => 'eventlog.type', |
|
| 85 | ], |
|
| 86 | 'message' => [ |
|
| 87 | 'title' => trans('general.text.message'), |
|
| 88 | ], |
|
| 89 | 'datetime' => [ |
|
| 90 | 'title' => trans('general.text.timestamp'), |
|
| 91 | ], |
|
| 92 | ]; |
|
| 93 | } |
|
| 94 | ||
| 95 | /** |
|
| 96 | * Get filename for export. |
|
| 97 | * |
|
| 98 | * @return string |
|
| 99 | */ |
|
| 100 | protected function filename() |
|
| 101 | { |
|
| 102 | return 'eventlog'; |
|
| 103 | } |
|
| 104 | ||
| 105 | /** |
|
| 106 | * Get Builder Params |
|
| 107 | * |
|
| 108 | * @return array |
|
| 109 | */ |
|
| 110 | protected function getBuilderParameters() |
|
| 111 | { |
|
| 112 | return [ |
|
| 113 | 'dom' => 'Blfrtip', |
|
| 114 | 'lengthMenu' => [[25, 50, 100, -1], [25, 50, 100, "All"]], |
|
| 115 | 'buttons' => [ |
|
| 116 | 'csv', 'excel', 'pdf', 'print', 'reset', 'reload', |
|
| 117 | ], |
|
| 118 | ]; |
|
| 119 | } |
|
| 120 | ||
| 121 | } |
|
| 122 | ||
| @@ 31-123 (lines=93) @@ | ||
| 28 | use App\Models\General\Inventory; |
|
| 29 | use Yajra\Datatables\Services\DataTable; |
|
| 30 | ||
| 31 | class InventoryDataTable extends DataTable |
|
| 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 | return '<a href="'.url("devices/".$inventory->device->device_id).'">'.$inventory->device->hostname.'</a>'; |
|
| 44 | }) |
|
| 45 | ->make(true); |
|
| 46 | } |
|
| 47 | ||
| 48 | /** |
|
| 49 | * Get the query object to be processed by datatables. |
|
| 50 | * |
|
| 51 | * @return \Illuminate\Database\Query\Builder|\Illuminate\Database\Eloquent\Builder |
|
| 52 | */ |
|
| 53 | public function query() |
|
| 54 | { |
|
| 55 | $inventory = Inventory::with('device')->select('entPhysical.*'); |
|
| 56 | return $this->applyScopes($inventory); |
|
| 57 | } |
|
| 58 | ||
| 59 | /** |
|
| 60 | * Optional method if you want to use html builder. |
|
| 61 | * |
|
| 62 | * @return \Yajra\Datatables\Html\Builder |
|
| 63 | */ |
|
| 64 | public function html() |
|
| 65 | { |
|
| 66 | return $this->builder() |
|
| 67 | ->columns($this->getColumns()) |
|
| 68 | ->parameters($this->getBuilderParameters()); |
|
| 69 | } |
|
| 70 | ||
| 71 | /** |
|
| 72 | * Get columns. |
|
| 73 | * |
|
| 74 | * @return array |
|
| 75 | */ |
|
| 76 | private function getColumns() |
|
| 77 | { |
|
| 78 | return [ |
|
| 79 | 'device.hostname' => [ |
|
| 80 | 'title' => trans('devices.label.hostname'), |
|
| 81 | ], |
|
| 82 | 'entPhysicalDescr' => [ |
|
| 83 | 'title' => trans('general.text.description'), |
|
| 84 | ], |
|
| 85 | 'entPhysicalName' => [ |
|
| 86 | 'title' => trans('general.text.name'), |
|
| 87 | ], |
|
| 88 | 'entPhysicalModelName' => [ |
|
| 89 | 'title' => trans('general.text.model'), |
|
| 90 | ], |
|
| 91 | 'entPhysicalSerialNum' => [ |
|
| 92 | 'title' => trans('general.text.serial'), |
|
| 93 | ], |
|
| 94 | ]; |
|
| 95 | } |
|
| 96 | ||
| 97 | /** |
|
| 98 | * Get filename for export. |
|
| 99 | * |
|
| 100 | * @return string |
|
| 101 | */ |
|
| 102 | protected function filename() |
|
| 103 | { |
|
| 104 | return 'inventory'; |
|
| 105 | } |
|
| 106 | ||
| 107 | /** |
|
| 108 | * Get Builder Params |
|
| 109 | * |
|
| 110 | * @return array |
|
| 111 | */ |
|
| 112 | protected function getBuilderParameters() |
|
| 113 | { |
|
| 114 | return [ |
|
| 115 | 'dom' => 'Blfrtip', |
|
| 116 | 'lengthMenu' => [[25, 50, 100, -1], [25, 50, 100, "All"]], |
|
| 117 | 'buttons' => [ |
|
| 118 | 'csv', 'excel', 'pdf', 'print', 'reset', 'reload', |
|
| 119 | ], |
|
| 120 | ]; |
|
| 121 | } |
|
| 122 | ||
| 123 | } |
|
| 124 | ||
| @@ 31-120 (lines=90) @@ | ||
| 28 | use App\Models\General\Syslog; |
|
| 29 | use Yajra\Datatables\Services\DataTable; |
|
| 30 | ||
| 31 | class SyslogDataTable extends DataTable |
|
| 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 | return '<a href="'.url("devices/".$syslog->device->device_id).'">'.$syslog->device->hostname.'</a>'; |
|
| 44 | }) |
|
| 45 | ->make(true); |
|
| 46 | } |
|
| 47 | ||
| 48 | /** |
|
| 49 | * Get the query object to be processed by datatables. |
|
| 50 | * |
|
| 51 | * @return \Illuminate\Database\Query\Builder|\Illuminate\Database\Eloquent\Builder |
|
| 52 | */ |
|
| 53 | public function query() |
|
| 54 | { |
|
| 55 | $syslog = Syslog::with('device')->select('syslog.*'); |
|
| 56 | return $this->applyScopes($syslog); |
|
| 57 | } |
|
| 58 | ||
| 59 | /** |
|
| 60 | * Optional method if you want to use html builder. |
|
| 61 | * |
|
| 62 | * @return \Yajra\Datatables\Html\Builder |
|
| 63 | */ |
|
| 64 | public function html() |
|
| 65 | { |
|
| 66 | return $this->builder() |
|
| 67 | ->columns($this->getColumns()) |
|
| 68 | ->parameters($this->getBuilderParameters()); |
|
| 69 | } |
|
| 70 | ||
| 71 | /** |
|
| 72 | * Get columns. |
|
| 73 | * |
|
| 74 | * @return array |
|
| 75 | */ |
|
| 76 | private function getColumns() |
|
| 77 | { |
|
| 78 | return [ |
|
| 79 | 'device.hostname' => [ |
|
| 80 | 'title' => trans('devices.label.hostname'), |
|
| 81 | ], |
|
| 82 | 'program' => [ |
|
| 83 | 'title' => trans('general.text.program'), |
|
| 84 | ], |
|
| 85 | 'msg' => [ |
|
| 86 | 'title' => trans('general.text.message'), |
|
| 87 | ], |
|
| 88 | 'timestamp' => [ |
|
| 89 | 'title' => trans('general.text.timestamp'), |
|
| 90 | ], |
|
| 91 | ]; |
|
| 92 | } |
|
| 93 | ||
| 94 | /** |
|
| 95 | * Get filename for export. |
|
| 96 | * |
|
| 97 | * @return string |
|
| 98 | */ |
|
| 99 | protected function filename() |
|
| 100 | { |
|
| 101 | return 'syslog'; |
|
| 102 | } |
|
| 103 | ||
| 104 | /** |
|
| 105 | * Get Builder Params |
|
| 106 | * |
|
| 107 | * @return array |
|
| 108 | */ |
|
| 109 | protected function getBuilderParameters() |
|
| 110 | { |
|
| 111 | return [ |
|
| 112 | 'dom' => 'Blfrtip', |
|
| 113 | 'lengthMenu' => [[25, 50, 100, -1], [25, 50, 100, "All"]], |
|
| 114 | 'buttons' => [ |
|
| 115 | 'csv', 'excel', 'pdf', 'print', 'reset', 'reload', |
|
| 116 | ], |
|
| 117 | ]; |
|
| 118 | } |
|
| 119 | ||
| 120 | } |
|
| 121 | ||