From 7e89ed41fd34f783b2a7d74a64514c08f6a09ce0 Mon Sep 17 00:00:00 2001
From: ChenCatherine <catherine@unisharp.com>
Date: Fri, 28 Jul 2017 19:05:27 +0800
Subject: [PATCH 1/4] Remove DispatchesJobs for supporting larval 5.0

---
 src/controllers/Controller.php | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/src/controllers/Controller.php b/src/controllers/Controller.php
index d0619013..62529c0b 100644
--- a/src/controllers/Controller.php
+++ b/src/controllers/Controller.php
@@ -2,11 +2,10 @@
 
 namespace Unisharp\Laravelfilemanager\controllers;
 
-use Illuminate\Foundation\Bus\DispatchesJobs;
 use Illuminate\Routing\Controller as BaseController;
 use Illuminate\Foundation\Validation\ValidatesRequests;
 
 abstract class Controller extends BaseController
 {
-    use DispatchesJobs, ValidatesRequests;
+    use ValidatesRequests;
 }

From 78146fa6584a014cd39a7892b68a838ae72e0208 Mon Sep 17 00:00:00 2001
From: ChenCatherine <catherine@unisharp.com>
Date: Fri, 28 Jul 2017 19:05:48 +0800
Subject: [PATCH 2/4] Remove auth helper

---
 src/Handlers/ConfigHandler.php | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/Handlers/ConfigHandler.php b/src/Handlers/ConfigHandler.php
index 8a4f19f2..a6f50bc1 100644
--- a/src/Handlers/ConfigHandler.php
+++ b/src/Handlers/ConfigHandler.php
@@ -6,6 +6,6 @@ class ConfigHandler
 {
     public function userField()
     {
-        return auth()->user()->id;
+        return \Auth::user()->id;
     }
 }

From f836ded358d980f2db19951d667d91c745a446b5 Mon Sep 17 00:00:00 2001
From: ChenCatherine <catherine@unisharp.com>
Date: Fri, 28 Jul 2017 19:06:21 +0800
Subject: [PATCH 3/4] Change route format for support larval 5.0

---
 src/routes.php            | 36 ++++++++++++++++++------------------
 src/traits/LfmHelpers.php |  2 +-
 2 files changed, 19 insertions(+), 19 deletions(-)

diff --git a/src/routes.php b/src/routes.php
index 49c847b0..4fba8e5e 100644
--- a/src/routes.php
+++ b/src/routes.php
@@ -5,96 +5,96 @@
     '\Unisharp\Laravelfilemanager\middlewares\CreateDefaultFolder',
 ]);
 $prefix = \Config::get('lfm.prefix', 'laravel-filemanager');
-$as = 'unisharp.lfm.';
+$as = 'unisharp.lfm';
 $namespace = '\Unisharp\Laravelfilemanager\controllers';
 
 // make sure authenticated
-Route::group(compact('middleware', 'prefix', 'as', 'namespace'), function () {
+Route::group(compact('middleware', 'prefix', 'namespace'), function () use ($as) {
 
     // Show LFM
     Route::get('/', [
         'uses' => 'LfmController@show',
-        'as' => 'show',
+        'as' => "{$as}.show",
     ]);
 
     // Show integration error messages
     Route::get('/errors', [
         'uses' => 'LfmController@getErrors',
-        'as' => 'getErrors',
+        'as' => "{$as}.getErrors",
     ]);
 
     // upload
     Route::any('/upload', [
         'uses' => 'UploadController@upload',
-        'as' => 'upload',
+        'as' => "{$as}.upload",
     ]);
 
     // list images & files
     Route::get('/jsonitems', [
         'uses' => 'ItemsController@getItems',
-        'as' => 'getItems',
+        'as' => "{$as}.getItems",
     ]);
 
     // folders
     Route::get('/newfolder', [
         'uses' => 'FolderController@getAddfolder',
-        'as' => 'getAddfolder',
+        'as' => "{$as}.getAddfolder",
     ]);
     Route::get('/deletefolder', [
         'uses' => 'FolderController@getDeletefolder',
-        'as' => 'getDeletefolder',
+        'as' => "{$as}.getDeletefolder",
     ]);
     Route::get('/folders', [
         'uses' => 'FolderController@getFolders',
-        'as' => 'getFolders',
+        'as' => "{$as}.getFolders",
     ]);
 
     // crop
     Route::get('/crop', [
         'uses' => 'CropController@getCrop',
-        'as' => 'getCrop',
+        'as' => "{$as}.getCrop",
     ]);
     Route::get('/cropimage', [
         'uses' => 'CropController@getCropimage',
-        'as' => 'getCropimage',
+        'as' => "{$as}.getCropimage",
     ]);
     Route::get('/cropnewimage', [
         'uses' => 'CropController@getNewCropimage',
-        'as' => 'getCropimage',
+        'as' => "{$as}.getCropimage",
     ]);
 
     // rename
     Route::get('/rename', [
         'uses' => 'RenameController@getRename',
-        'as' => 'getRename',
+        'as' => "{$as}.getRename",
     ]);
 
     // scale/resize
     Route::get('/resize', [
         'uses' => 'ResizeController@getResize',
-        'as' => 'getResize',
+        'as' => "{$as}.getResize",
     ]);
     Route::get('/doresize', [
         'uses' => 'ResizeController@performResize',
-        'as' => 'performResize',
+        'as' => "{$as}.performResize",
     ]);
 
     // download
     Route::get('/download', [
         'uses' => 'DownloadController@getDownload',
-        'as' => 'getDownload',
+        'as' => "{$as}.getDownload",
     ]);
 
     // delete
     Route::get('/delete', [
         'uses' => 'DeleteController@getDelete',
-        'as' => 'getDelete',
+        'as' => "{$as}.getDelete",
     ]);
 
     Route::get('/demo', 'DemoController@index');
 });
 
-Route::group(compact('prefix', 'as', 'namespace'), function () {
+Route::group(compact('prefix', 'namespace'), function () {
     // Get file when base_directory isn't public
     $images_url = '/' . \Config::get('lfm.images_folder_name') . '/{base_path}/{image_name}';
     $files_url = '/' . \Config::get('lfm.files_folder_name') . '/{base_path}/{file_name}';
diff --git a/src/traits/LfmHelpers.php b/src/traits/LfmHelpers.php
index 39bc7480..1ad55e83 100644
--- a/src/traits/LfmHelpers.php
+++ b/src/traits/LfmHelpers.php
@@ -332,7 +332,7 @@ public function translateToUtf8($input)
      */
     public function isProcessingImages()
     {
-        return lcfirst(str_singular(request('type'))) === 'image';
+        return lcfirst(str_singular(\Request::input('type'))) === 'image';
     }
 
     /**

From 98b248e71428706d34885793ba582e9e57c0ffc9 Mon Sep 17 00:00:00 2001
From: ChenCatherine <catherine@unisharp.com>
Date: Mon, 31 Jul 2017 11:23:45 +0800
Subject: [PATCH 4/4] Change request helper to facade

---
 src/controllers/CropController.php     | 25 +++++++++++++------------
 src/controllers/DeleteController.php   |  5 +++--
 src/controllers/DownloadController.php |  6 ++++--
 src/controllers/FolderController.php   |  5 +++--
 src/controllers/ItemsController.php    | 11 ++++++-----
 src/controllers/RedirectController.php |  4 ++--
 src/controllers/RenameController.php   |  7 ++++---
 src/controllers/ResizeController.php   | 17 +++++++++--------
 src/controllers/UploadController.php   |  5 +++--
 src/traits/LfmHelpers.php              |  2 +-
 src/views/index.blade.php              |  2 +-
 11 files changed, 49 insertions(+), 40 deletions(-)

diff --git a/src/controllers/CropController.php b/src/controllers/CropController.php
index 29a2f5e6..441b564b 100644
--- a/src/controllers/CropController.php
+++ b/src/controllers/CropController.php
@@ -2,6 +2,7 @@
 
 namespace Unisharp\Laravelfilemanager\controllers;
 
+use Illuminate\Http\Request;
 use Intervention\Image\Facades\Image;
 use Unisharp\Laravelfilemanager\Events\ImageIsCropping;
 use Unisharp\Laravelfilemanager\Events\ImageWasCropped;
@@ -16,10 +17,10 @@ class CropController extends LfmController
      *
      * @return mixed
      */
-    public function getCrop()
+    public function getCrop(Request $request)
     {
-        $working_dir = request('working_dir');
-        $img = parent::objectPresenter(parent::getCurrentPath(request('img')));
+        $working_dir = $request->input('working_dir');
+        $img = parent::objectPresenter(parent::getCurrentPath($request->input('img')));
 
         return view('laravel-filemanager::crop')
             ->with(compact('working_dir', 'img'));
@@ -28,17 +29,17 @@ public function getCrop()
     /**
      * Crop the image (called via ajax).
      */
-    public function getCropimage($overWrite = true)
+    public function getCropimage($request, $overWrite = true)
     {
-        $dataX = request('dataX');
-        $dataY = request('dataY');
-        $dataHeight = request('dataHeight');
-        $dataWidth = request('dataWidth');
-        $image_path = parent::getCurrentPath(request('img'));
+        $dataX = $request->input('dataX');
+        $dataY = $request->input('dataY');
+        $dataHeight = $request->input('dataHeight');
+        $dataWidth = $request->input('dataWidth');
+        $image_path = parent::getCurrentPath($request->input('img'));
         $crop_path = $image_path;
 
         if (! $overWrite) {
-            $fileParts = explode('.', request('img'));
+            $fileParts = explode('.', $request->input('img'));
             $fileParts[count($fileParts) - 2] = $fileParts[count($fileParts) - 2] . '_cropped_' . time();
             $crop_path = parent::getCurrentPath(implode('.', $fileParts));
         }
@@ -56,8 +57,8 @@ public function getCropimage($overWrite = true)
         event(new ImageWasCropped($image_path));
     }
 
-    public function getNewCropimage()
+    public function getNewCropimage(Request $request)
     {
-        $this->getCropimage(false);
+        $this->getCropimage($request, false);
     }
 }
diff --git a/src/controllers/DeleteController.php b/src/controllers/DeleteController.php
index 5fdc8f1d..50d97985 100644
--- a/src/controllers/DeleteController.php
+++ b/src/controllers/DeleteController.php
@@ -2,6 +2,7 @@
 
 namespace Unisharp\Laravelfilemanager\controllers;
 
+use Illuminate\Http\Request;
 use Illuminate\Support\Facades\File;
 use Unisharp\Laravelfilemanager\Events\ImageIsDeleting;
 use Unisharp\Laravelfilemanager\Events\ImageWasDeleted;
@@ -16,9 +17,9 @@ class DeleteController extends LfmController
      *
      * @return mixed
      */
-    public function getDelete()
+    public function getDelete(Request $request)
     {
-        $name_to_delete = request('items');
+        $name_to_delete = $request->input('items');
 
         $file_to_delete = parent::getCurrentPath($name_to_delete);
         $thumb_to_delete = parent::getThumbPath($name_to_delete);
diff --git a/src/controllers/DownloadController.php b/src/controllers/DownloadController.php
index 3de69554..eb6d28ea 100644
--- a/src/controllers/DownloadController.php
+++ b/src/controllers/DownloadController.php
@@ -2,6 +2,8 @@
 
 namespace Unisharp\Laravelfilemanager\controllers;
 
+use Illuminate\Http\Request;
+
 /**
  * Class DownloadController.
  */
@@ -12,8 +14,8 @@ class DownloadController extends LfmController
      *
      * @return mixed
      */
-    public function getDownload()
+    public function getDownload(Request $request)
     {
-        return response()->download(parent::getCurrentPath(request('file')));
+        return response()->download(parent::getCurrentPath($request->input('file')));
     }
 }
diff --git a/src/controllers/FolderController.php b/src/controllers/FolderController.php
index e52e2605..5a58ed40 100644
--- a/src/controllers/FolderController.php
+++ b/src/controllers/FolderController.php
@@ -2,6 +2,7 @@
 
 namespace Unisharp\Laravelfilemanager\controllers;
 
+use Illuminate\Http\Request;
 use Illuminate\Support\Facades\File;
 
 /**
@@ -52,9 +53,9 @@ public function getFolders()
      *
      * @return mixed
      */
-    public function getAddfolder()
+    public function getAddfolder(Request $request)
     {
-        $folder_name = parent::translateFromUtf8(trim(request('name')));
+        $folder_name = parent::translateFromUtf8(trim($request->input('name')));
 
         $path = parent::getCurrentPath($folder_name);
 
diff --git a/src/controllers/ItemsController.php b/src/controllers/ItemsController.php
index b0532998..5a482922 100644
--- a/src/controllers/ItemsController.php
+++ b/src/controllers/ItemsController.php
@@ -1,6 +1,7 @@
 <?php
 
 namespace Unisharp\Laravelfilemanager\controllers;
+use Illuminate\Http\Request;
 
 /**
  * Class ItemsController.
@@ -12,16 +13,16 @@ class ItemsController extends LfmController
      *
      * @return mixed
      */
-    public function getItems()
+    public function getItems(Request $request)
     {
         $path = parent::getCurrentPath();
-        $sort_type = request('sort_type');
+        $sort_type = $request->input('sort_type');
 
         $files = parent::sortFilesAndDirectories(parent::getFilesWithInfo($path), $sort_type);
         $directories = parent::sortFilesAndDirectories(parent::getDirectories($path), $sort_type);
 
         return [
-            'html' => (string) view($this->getView())->with([
+            'html' => (string) view($this->getView($request))->with([
                 'files'       => $files,
                 'directories' => $directories,
                 'items'       => array_merge($directories, $files),
@@ -30,10 +31,10 @@ public function getItems()
         ];
     }
 
-    private function getView()
+    private function getView($request)
     {
         $view_type = 'grid';
-        $show_list = request('show_list');
+        $show_list = $request->input('show_list');
 
         if ($show_list === '1') {
             $view_type = 'list';
diff --git a/src/controllers/RedirectController.php b/src/controllers/RedirectController.php
index f7c770f9..a4805905 100644
--- a/src/controllers/RedirectController.php
+++ b/src/controllers/RedirectController.php
@@ -13,10 +13,10 @@ class RedirectController extends LfmController
 {
     private $file_path;
 
-    public function __construct()
+    public function __construct(Request $request)
     {
         $delimiter = config('lfm.prefix') . '/';
-        $url = urldecode(request()->url());
+        $url = urldecode($request->url());
         // dd($delimiter);
         $external_path = substr($url, strpos($url, $delimiter) + strlen($delimiter));
 
diff --git a/src/controllers/RenameController.php b/src/controllers/RenameController.php
index fefc5811..7bf48ddd 100644
--- a/src/controllers/RenameController.php
+++ b/src/controllers/RenameController.php
@@ -2,6 +2,7 @@
 
 namespace Unisharp\Laravelfilemanager\controllers;
 
+use Illuminate\Http\Request;
 use Illuminate\Support\Facades\File;
 use Unisharp\Laravelfilemanager\Events\ImageIsRenaming;
 use Unisharp\Laravelfilemanager\Events\ImageWasRenamed;
@@ -16,10 +17,10 @@ class RenameController extends LfmController
     /**
      * @return string
      */
-    public function getRename()
+    public function getRename(Request $request)
     {
-        $old_name = parent::translateFromUtf8(request('file'));
-        $new_name = parent::translateFromUtf8(trim(request('new_name')));
+        $old_name = parent::translateFromUtf8($request->input('file'));
+        $new_name = parent::translateFromUtf8(trim($request->input('new_name')));
 
         $old_file = parent::getCurrentPath($old_name);
 
diff --git a/src/controllers/ResizeController.php b/src/controllers/ResizeController.php
index 398b2087..868ecba0 100644
--- a/src/controllers/ResizeController.php
+++ b/src/controllers/ResizeController.php
@@ -2,6 +2,7 @@
 
 namespace Unisharp\Laravelfilemanager\controllers;
 
+use Illuminate\Http\Request;
 use Intervention\Image\Facades\Image;
 use Unisharp\Laravelfilemanager\Events\ImageIsResizing;
 use Unisharp\Laravelfilemanager\Events\ImageWasResized;
@@ -16,10 +17,10 @@ class ResizeController extends LfmController
      *
      * @return mixed
      */
-    public function getResize()
+    public function getResize(Request $request)
     {
         $ratio = 1.0;
-        $image = request('img');
+        $image = $request->input('img');
 
         $original_image = Image::make(parent::getCurrentPath($image));
         $original_width = $original_image->width();
@@ -54,13 +55,13 @@ public function getResize()
             ->with('ratio', $ratio);
     }
 
-    public function performResize()
+    public function performResize(Request $request)
     {
-        $dataX = request('dataX');
-        $dataY = request('dataY');
-        $height = request('dataHeight');
-        $width = request('dataWidth');
-        $image_path = parent::getCurrentPath(request('img'));
+        $dataX = $request->input('dataX');
+        $dataY = $request->input('dataY');
+        $height = $request->input('dataHeight');
+        $width = $request->input('dataWidth');
+        $image_path = parent::getCurrentPath($request->input('img'));
 
         event(new ImageIsResizing($image_path));
         Image::make($image_path)->resize($width, $height)->save();
diff --git a/src/controllers/UploadController.php b/src/controllers/UploadController.php
index d7ec35bf..ebb286f4 100644
--- a/src/controllers/UploadController.php
+++ b/src/controllers/UploadController.php
@@ -2,6 +2,7 @@
 
 namespace Unisharp\Laravelfilemanager\controllers;
 
+use Illuminate\Http\Request;
 use Illuminate\Support\Facades\File;
 use Intervention\Image\Facades\Image;
 use Symfony\Component\HttpFoundation\File\UploadedFile;
@@ -19,9 +20,9 @@ class UploadController extends LfmController
      * @param UploadRequest $request
      * @return string
      */
-    public function upload()
+    public function upload(Request $request)
     {
-        $files = request()->file('upload');
+        $files = $request->file('upload');
         $error_bag = [];
         foreach (is_array($files) ? $files : [$files] as $file) {
             $validation_message = $this->uploadValidator($file);
diff --git a/src/traits/LfmHelpers.php b/src/traits/LfmHelpers.php
index 1ad55e83..3239000e 100644
--- a/src/traits/LfmHelpers.php
+++ b/src/traits/LfmHelpers.php
@@ -123,7 +123,7 @@ public function getPathPrefix($type)
      */
     private function getFormatedWorkingDir()
     {
-        $working_dir = request('working_dir');
+        $working_dir = \Request::input('working_dir');
 
         if (empty($working_dir)) {
             $default_folder_type = 'share';
diff --git a/src/views/index.blade.php b/src/views/index.blade.php
index f015d7b0..eff850b9 100644
--- a/src/views/index.blade.php
+++ b/src/views/index.blade.php
@@ -129,7 +129,7 @@
               </div>
             </div>
             <input type='hidden' name='working_dir' id='working_dir'>
-            <input type='hidden' name='type' id='type' value='{{ request("type") }}'>
+            <input type='hidden' name='type' id='type' value='{{ \Request::input("type") }}'>
             <input type='hidden' name='_token' value='{{csrf_token()}}'>
           </form>
         </div>
