| 1 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  | namespace UniSharp\LaravelFilemanager\Controllers; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  | use Illuminate\Support\Facades\Storage; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  | use UniSharp\LaravelFilemanager\Events\FileIsMoving; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  | use UniSharp\LaravelFilemanager\Events\FileWasMoving; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  | use UniSharp\LaravelFilemanager\Events\FolderIsMoving; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  | use UniSharp\LaravelFilemanager\Events\FolderWasMoving; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  | class ItemsController extends LfmController | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  | { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  |      * Get the images to load for a selected folder. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  |      * @return mixed | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 |  |  |     public function getItems() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 19 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 20 |  |  |         $currentPage = self::getCurrentPageFromRequest(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 21 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 22 |  |  |         $perPage = $this->helper->getPaginationPerPage(); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 23 |  |  |         $items = array_merge($this->lfm->folders(), $this->lfm->files()); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 24 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 25 |  |  |         return [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 26 |  |  |             'items' => array_map(function ($item) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 27 |  |  |                 return $item->fill()->attributes; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 28 |  |  |             }, array_slice($items, ($currentPage - 1) * $perPage, $perPage)), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 29 |  |  |             'paginator' => [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 30 |  |  |                 'current_page' => $currentPage, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 31 |  |  |                 'total' => count($items), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 32 |  |  |                 'per_page' => $perPage, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 33 |  |  |             ], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 34 |  |  |             'display' => $this->helper->getDisplayMode(), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 35 |  |  |             'working_dir' => $this->lfm->path('working_dir'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 36 |  |  |         ]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 37 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 38 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 39 |  |  |     public function move() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 40 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 41 |  |  |         $items = request('items'); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 42 |  |  |         $folder_types = array_filter(['user', 'share'], function ($type) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 43 |  |  |             return $this->helper->allowFolderType($type); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 44 |  |  |         }); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 45 |  |  |         return view('laravel-filemanager::move') | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 46 |  |  |             ->with([ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 47 |  |  |                 'root_folders' => array_map(function ($type) use ($folder_types) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 48 |  |  |                     $path = $this->lfm->dir($this->helper->getRootFolder($type)); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 49 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 50 |  |  |                     return (object) [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 51 |  |  |                         'name' => trans('laravel-filemanager::lfm.title-' . $type), | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 52 |  |  |                         'url' => $path->path('working_dir'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 53 |  |  |                         'children' => $path->folders(), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 54 |  |  |                         'has_next' => ! ($type == end($folder_types)), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 55 |  |  |                     ]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 56 |  |  |                 }, $folder_types), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 57 |  |  |             ]) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 58 |  |  |             ->with('items', $items); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 59 |  |  |     } | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 60 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 61 |  |  |     public function doMove() | 
            
                                                                        
                            
            
                                    
            
            
                | 62 |  |  |     { | 
            
                                                                        
                            
            
                                    
            
            
                | 63 |  |  |         $target = $this->helper->input('goToFolder'); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                        
                            
            
                                    
            
            
                | 64 |  |  |         $items = $this->helper->input('items'); | 
            
                                                                        
                            
            
                                    
            
            
                | 65 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 66 |  |  |         foreach ($items as $item) { | 
            
                                                                        
                            
            
                                    
            
            
                | 67 |  |  |             $old_file = $this->lfm->pretty($item); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                        
                            
            
                                    
            
            
                | 68 |  |  |             $is_directory = $old_file->isDirectory(); | 
            
                                                                        
                            
            
                                    
            
            
                | 69 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 70 |  |  |             $file = $this->lfm->setName($item); | 
            
                                                                        
                            
            
                                    
            
            
                | 71 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 72 |  |  |             if (!Storage::disk($this->helper->config('disk'))->exists($file->path('storage'))) { | 
            
                                                                        
                            
            
                                    
            
            
                | 73 |  |  |                 abort(404); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                        
                            
            
                                    
            
            
                | 74 |  |  |             } | 
            
                                                                        
                            
            
                                    
            
            
                | 75 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 76 |  |  |             $old_path = $old_file->path(); | 
            
                                                                        
                            
            
                                    
            
            
                | 77 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 78 |  |  |             if ($old_file->hasThumb()) { | 
            
                                                                        
                            
            
                                    
            
            
                | 79 |  |  |                 $new_file = $this->lfm->setName($item)->thumb()->dir($target); | 
            
                                                                        
                            
            
                                    
            
            
                | 80 |  |  |                 if ($is_directory) { | 
            
                                                                        
                            
            
                                    
            
            
                | 81 |  |  |                     event(new FolderIsMoving($old_file->path(), $new_file->path())); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                        
                            
            
                                    
            
            
                | 82 |  |  |                 } else { | 
            
                                                                        
                            
            
                                    
            
            
                | 83 |  |  |                     event(new FileIsMoving($old_file->path(), $new_file->path())); | 
            
                                                                        
                            
            
                                    
            
            
                | 84 |  |  |                 } | 
            
                                                                        
                            
            
                                    
            
            
                | 85 |  |  |                 $this->lfm->setName($item)->thumb()->move($new_file); | 
            
                                                                        
                            
            
                                    
            
            
                | 86 |  |  |             } | 
            
                                                                        
                            
            
                                    
            
            
                | 87 |  |  |             $new_file = $this->lfm->setName($item)->dir($target); | 
            
                                                                        
                            
            
                                    
            
            
                | 88 |  |  |             $this->lfm->setName($item)->move($new_file); | 
            
                                                                        
                            
            
                                    
            
            
                | 89 |  |  |             if ($is_directory) { | 
            
                                                                        
                            
            
                                    
            
            
                | 90 |  |  |                 event(new FolderWasMoving($old_path, $new_file->path())); | 
            
                                                                        
                            
            
                                    
            
            
                | 91 |  |  |             } else { | 
            
                                                                        
                            
            
                                    
            
            
                | 92 |  |  |                 event(new FileWasMoving($old_path, $new_file->path())); | 
            
                                                                        
                            
            
                                    
            
            
                | 93 |  |  |             } | 
            
                                                                        
                            
            
                                    
            
            
                | 94 |  |  |         }; | 
            
                                                                        
                            
            
                                    
            
            
                | 95 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 96 |  |  |         return parent::$success_response; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 97 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 98 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 99 |  |  |     private static function getCurrentPageFromRequest() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 100 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 101 |  |  |         $currentPage = (int) request()->get('page', 1); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 102 |  |  |         $currentPage = $currentPage < 1 ? 1 : $currentPage; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 103 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 104 |  |  |         return $currentPage; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 105 |  |  |     } | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 106 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 107 |  |  |  | 
            
                        
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.