| 1 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  | namespace App\DataTables; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  | use Yajra\DataTables\Services\DataTable; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  | use App\Sensor; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  | class SensorDataTable extends DataTable | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  | { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  |      * Build DataTable class. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  |      * @return \Yajra\DataTables\Engines\BaseEngine | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 14 |  |  |      */ | 
            
                                                                        
                            
            
                                    
            
            
                | 15 |  |  |     public function dataTable($query) | 
            
                                                                        
                            
            
                                    
            
            
                | 16 |  |  |     { | 
            
                                                                        
                            
            
                                    
            
            
                | 17 |  |  |         return datatables($query) | 
            
                                                                        
                            
            
                                    
            
            
                | 18 |  |  |             ->editColumn('name', function($sensor) { | 
            
                                                                        
                            
            
                                    
            
            
                | 19 |  |  |                 return '<a href="'.route('sensor.show', $sensor->id).'">'.$sensor->name.'</a>'; | 
            
                                                                        
                            
            
                                    
            
            
                | 20 |  |  |             }) | 
            
                                                                        
                            
            
                                    
            
            
                | 21 |  |  |             ->editColumn('device_id', function($sensor) { | 
            
                                                                        
                            
            
                                    
            
            
                | 22 |  |  |                 return '<a href="'.route('device.show', $sensor->device_id).'">'.($sensor->device->name ?? '').'</a>'; | 
            
                                                                        
                            
            
                                    
            
            
                | 23 |  |  |             }) | 
            
                                                                        
                            
            
                                    
            
            
                | 24 |  |  |             ->addColumn('value', function($sensor) { | 
            
                                                                        
                            
            
                                    
            
            
                | 25 |  |  |                 return '<a href="'.route('sensordata.show', $sensor->latest_data->id ?? '0').'">'.($sensor->latest_data->value ?? 'null').'</a>'; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                        
                            
            
                                    
            
            
                | 26 |  |  |             }) | 
            
                                                                        
                            
            
                                    
            
            
                | 27 |  |  |             ->addColumn('action', 'sensor.action') | 
            
                                                                        
                            
            
                                    
            
            
                | 28 |  |  |             ->blacklist([ 'value', 'action' ]) | 
            
                                                                        
                            
            
                                    
            
            
                | 29 |  |  |             ->rawColumns([ 'device_id', 'name', 'value', 'action' ]); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 30 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 31 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 32 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 33 |  |  |      * Get the query object to be processed by dataTables. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 34 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 35 |  |  |      * @return \Illuminate\Database\Eloquent\Builder|\Illuminate\Database\Query\Builder|\Illuminate\Support\Collection | 
            
                                                                                                            
                            
            
                                    
            
            
                | 36 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 37 |  |  |     public function query() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 38 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 39 |  |  |         $query = Sensor::query(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 40 |  |  |         return $this->applyScopes($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 41 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 42 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 43 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 44 |  |  |      * Optional method if you want to use html builder. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 45 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 46 |  |  |      * @return \Yajra\DataTables\Html\Builder | 
            
                                                                                                            
                            
            
                                    
            
            
                | 47 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 48 |  |  |     public function html() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 49 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 50 |  |  |         return $this->builder() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 51 |  |  |             ->columns($this->getColumns()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 52 |  |  |             ->minifiedAjax() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 53 |  |  |             ->parameters($this->getBuilderParameters()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 54 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 55 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 56 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 57 |  |  |      * Get columns. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 58 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 59 |  |  |      * @return array | 
            
                                                                                                            
                            
            
                                    
            
            
                | 60 |  |  |      */ | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 61 |  | View Code Duplication |     protected function getColumns() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 62 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 63 |  |  |         return [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 64 |  |  |             'id', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 65 |  |  |             'name', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 66 |  |  |             [ 'data' => 'device_id', 'name' => 'device_id', 'title' => 'Device' ], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 67 |  |  |             'type', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 68 |  |  |             'value', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 69 |  |  |             [ 'data' => 'action', 'name' => 'action', 'title' => 'Action', 'searchable' => false, 'orderable' => false, 'exportable' => false, 'printable' => false ] | 
            
                                                                                                            
                            
            
                                    
            
            
                | 70 |  |  |         ]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 71 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 72 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 73 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 74 |  |  |      * Get builder parameters. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 75 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 76 |  |  |      * @return array | 
            
                                                                                                            
                            
            
                                    
            
            
                | 77 |  |  |      */ | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 78 |  | View Code Duplication |     protected function getBuilderParameters() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 79 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 80 |  |  |         return [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 81 |  |  |             'dom'     => 'Bfrtip', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 82 |  |  |             'order'   => [ [ 0, 'desc' ] ], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 83 |  |  |             'buttons' => [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 84 |  |  |                 'create', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 85 |  |  |                 [ 'extend' => 'collection', 'text' => '<i class="fa fa-file-excel-o"></i> Export', 'buttons' => [  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 86 |  |  |                     [ 'extend' => 'csv', 'exportOptions' => [ 'modifier' => [ 'search' => true ] ] ], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 87 |  |  |                     [ 'extend' => 'excel', 'exportOptions' => [ 'modifier' => [ 'search' => true ] ] ], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 88 |  |  |                 ] ], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 89 |  |  |                 [ 'extend' => 'print', 'exportOptions' => [ 'modifier' => [ 'search' => true ] ] ], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 90 |  |  |                 'reset', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 91 |  |  |                 'reload', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 92 |  |  |             ], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 93 |  |  |             'paging' => true, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 94 |  |  |             'searching' => true, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 95 |  |  |             'info' => true, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 96 |  |  |             'searchDelay' => 500, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 97 |  |  |         ]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 98 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 99 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 100 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 101 |  |  |      * Get filename for export. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 102 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 103 |  |  |      * @return string | 
            
                                                                                                            
                            
            
                                    
            
            
                | 104 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 105 |  |  |     protected function filename() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 106 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 107 |  |  |         return 'sensor_'.time(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 108 |  |  |     } | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 109 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 110 |  |  |  | 
            
                        
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths