44use Illuminate \Support \Facades \Config ;
55use Illuminate \Support \Facades \File ;
66use Illuminate \Support \Facades \Input ;
7- use Illuminate \Support \Facades \Session ;
7+ use Illuminate \Support \Facades \Request ;
88use Illuminate \Support \Facades \View ;
99use Intervention \Image \Facades \Image ;
1010
@@ -17,16 +17,27 @@ class LfmController extends Controller {
1717 /**
1818 * @var
1919 */
20- public $ file_location ;
21- public $ dir_location ;
20+ public $ file_location = null ;
21+ public $ dir_location = null ;
22+ public $ file_type = null ;
2223
2324
2425 /**
2526 * Constructor
2627 */
2728 public function __construct ()
2829 {
29- $ this ->setPathAndType ();
30+ $ this ->file_type = Input::get ('type ' , 'Images ' ); // default set to Images.
31+
32+ if ('Images ' === $ this ->file_type ) {
33+ $ this ->dir_location = Config::get ('lfm.images_url ' );
34+ $ this ->file_location = Config::get ('lfm.images_dir ' );
35+ } elseif ('Files ' === $ this ->file_type ) {
36+ $ this ->dir_location = Config::get ('lfm.files_url ' );
37+ $ this ->file_location = Config::get ('lfm.files_dir ' );
38+ } else {
39+ throw new \Exception ('unexpected type parameter ' );
40+ }
3041
3142 $ this ->checkMyFolderExists ();
3243
@@ -48,7 +59,8 @@ public function show()
4859 }
4960
5061 return View::make ('laravel-filemanager::index ' )
51- ->with ('working_dir ' , $ working_dir );
62+ ->with ('working_dir ' , $ working_dir )
63+ ->with ('file_type ' , $ this ->file_type );
5264 }
5365
5466
@@ -57,22 +69,6 @@ public function show()
5769 *****************************/
5870
5971
60- private function setPathAndType ()
61- {
62- // dd('type:'.Input::get('type'));
63-
64- if (Input::has ('type ' ) && Input::get ('type ' ) === 'Files ' ) {
65- Session::put ('lfm_type ' , 'Files ' );
66- Session::put ('lfm.file_location ' , Config::get ('lfm.files_dir ' ));
67- Session::put ('lfm.dir_location ' , Config::get ('lfm.files_url ' ));
68- } else if (Input::has ('type ' ) && Input::get ('type ' ) === 'Images ' ) {
69- Session::put ('lfm_type ' , 'Images ' );
70- Session::put ('lfm.file_location ' , Config::get ('lfm.images_dir ' ));
71- Session::put ('lfm.dir_location ' , Config::get ('lfm.images_url ' ));
72- }
73- }
74-
75-
7672 private function checkMyFolderExists ()
7773 {
7874 if (\Config::get ('lfm.allow_multi_user ' ) === true ) {
@@ -122,7 +118,7 @@ private function formatLocation($location, $type = null)
122118
123119 public function getPath ($ type = null )
124120 {
125- $ path = base_path () . '/ ' . Session:: get ( ' lfm. file_location' ) ;
121+ $ path = base_path () . '/ ' . $ this -> file_location ;
126122
127123 $ path = $ this ->formatLocation ($ path , $ type );
128124
@@ -132,7 +128,7 @@ public function getPath($type = null)
132128
133129 public function getUrl ($ type = null )
134130 {
135- $ url = Session:: get ( ' lfm. dir_location' ) ;
131+ $ url = $ this -> dir_location ;
136132
137133 $ url = $ this ->formatLocation ($ url , $ type );
138134
0 commit comments