| 1 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  | namespace App\DataTables; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  | use App\User; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  | use Yajra\DataTables\Services\DataTable; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  | class UsersDataTable 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(User $user) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 19 |  |  |                 return '<a href="'.route('user.show', $user->id).'">'.$user->name.'</a>'; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 20 |  |  |             }) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 21 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 22 |  |  |             ->editColumn('role', function(User $user) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 23 |  |  |                 return $user->roleString(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 24 |  |  |             }) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 25 |  |  |             ->editColumn('updated_at', function($user) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 26 |  |  |                 return $user->updatedAtHuman; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 27 |  |  |             }) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 28 |  |  |             ->editColumn('created_at', function($user) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 29 |  |  |                 return $user->createdAtHuman; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 30 |  |  |             }) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 31 |  |  |             ->addColumn('action', 'user.action') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 32 |  |  |             ->blacklist([ 'action' ]) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 33 |  |  |             ->rawColumns([ 'name', 'action' ]) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 34 |  |  |             ->setRowData([ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 35 |  |  |                     'data-id' => function($user) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 36 |  |  |                         return 'row-'.$user->id; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 37 |  |  |                     }, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 38 |  |  |                     'data-name' => function($user) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 39 |  |  |                         return 'row-'.$user->name; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 40 |  |  |                     }, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 41 |  |  |             ]); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 42 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 43 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 44 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 45 |  |  |      * Get the query object to be processed by dataTables. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 46 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 47 |  |  |      * @return \Illuminate\Database\Eloquent\Builder|\Illuminate\Database\Query\Builder|\Illuminate\Support\Collection | 
            
                                                                                                            
                            
            
                                    
            
            
                | 48 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 49 |  |  |     public function query() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 50 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 51 |  |  |         $query = User::query(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 52 |  |  |          | 
            
                                                                                                            
                            
            
                                    
            
            
                | 53 |  |  |         return $this->applyScopes($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 54 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 55 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 56 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 57 |  |  |      * Optional method if you want to use html builder. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 58 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 59 |  |  |      * @return \Yajra\DataTables\Html\Builder | 
            
                                                                                                            
                            
            
                                    
            
            
                | 60 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 61 |  |  |     public function html() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 62 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 63 |  |  |         return $this->builder() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 64 |  |  |                     ->columns($this->getColumns()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 65 |  |  |                     ->minifiedAjax() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 66 |  |  |                     //->addAction(['width' => '160px']) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 67 |  |  |                     ->parameters([ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 68 |  |  |                         'dom'     => 'Bfrtip', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 69 |  |  |                         'order'   => [ [ 0, 'asc' ] ], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 70 |  |  |                         'buttons' => [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 71 |  |  |                             'create', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 72 |  |  |                 [ 'extend' => 'collection', 'text' => '<i class="fa fa-file-excel-o"></i> Export', 'buttons' => [  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 73 |  |  |                     [ 'extend' => 'csv', 'exportOptions' => [ 'modifier' => [ 'search' => true ] ] ], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 74 |  |  |                     [ 'extend' => 'excel', 'exportOptions' => [ 'modifier' => [ 'search' => true ] ] ], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 75 |  |  |                 ] ], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 76 |  |  |                 [ 'extend' => 'print', 'exportOptions' => [ 'modifier' => [ 'search' => true ] ] ], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 77 |  |  |                             'reset', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 78 |  |  |                             'reload', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 79 |  |  |                         ], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 80 |  |  |                         'paging' => true, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 81 |  |  |                         'searching' => true, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 82 |  |  |                         'info' => true, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 83 |  |  |                         'searchDelay' => 500, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 84 |  |  |                     ]); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 85 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 86 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 87 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 88 |  |  |      * Get columns. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 89 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 90 |  |  |      * @return array | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 91 |  |  |      */ | 
            
                                                                        
                            
            
                                    
            
            
                | 92 |  |  |     protected function getColumns() | 
            
                                                                        
                            
            
                                    
            
            
                | 93 |  |  |     { | 
            
                                                                        
                            
            
                                    
            
            
                | 94 |  |  |         return [ | 
            
                                                                        
                            
            
                                    
            
            
                | 95 |  |  |             'id', | 
            
                                                                        
                            
            
                                    
            
            
                | 96 |  |  |             'name', | 
            
                                                                        
                            
            
                                    
            
            
                | 97 |  |  |             'email', | 
            
                                                                        
                            
            
                                    
            
            
                | 98 |  |  |             'phone', | 
            
                                                                        
                            
            
                                    
            
            
                | 99 |  |  |             'role', | 
            
                                                                        
                            
            
                                    
            
            
                | 100 |  |  |             'created_at', | 
            
                                                                        
                            
            
                                    
            
            
                | 101 |  |  |             'updated_at', | 
            
                                                                        
                            
            
                                    
            
            
                | 102 |  |  |             [ 'name' => 'action', 'data' => 'action', 'title' => 'Actions', 'render' => null, 'searchable' => false, 'orderable' => false, 'exportable' => false, 'printable' => true, 'footer' => '' ], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 103 |  |  |         ]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 104 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 105 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 106 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 107 |  |  |      * Get filename for export. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 108 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 109 |  |  |      * @return string | 
            
                                                                                                            
                            
            
                                    
            
            
                | 110 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 111 |  |  |     protected function filename() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 112 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 113 |  |  |         return 'users_'.time(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 114 |  |  |     } | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 115 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 116 |  |  |  | 
            
                        
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