4
4
use Illuminate \Support \Facades \Config ;
5
5
use Illuminate \Support \Facades \File ;
6
6
use Illuminate \Support \Facades \Input ;
7
- use Illuminate \Support \Facades \Session ;
7
+ use Illuminate \Support \Facades \Request ;
8
8
use Illuminate \Support \Facades \View ;
9
9
use Intervention \Image \Facades \Image ;
10
10
@@ -17,16 +17,27 @@ class LfmController extends Controller {
17
17
/**
18
18
* @var
19
19
*/
20
- public $ file_location ;
21
- public $ dir_location ;
20
+ public $ file_location = null ;
21
+ public $ dir_location = null ;
22
+ public $ file_type = null ;
22
23
23
24
24
25
/**
25
26
* Constructor
26
27
*/
27
28
public function __construct ()
28
29
{
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
+ }
30
41
31
42
$ this ->checkMyFolderExists ();
32
43
@@ -48,7 +59,8 @@ public function show()
48
59
}
49
60
50
61
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 );
52
64
}
53
65
54
66
@@ -57,22 +69,6 @@ public function show()
57
69
*****************************/
58
70
59
71
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
-
76
72
private function checkMyFolderExists ()
77
73
{
78
74
if (\Config::get ('lfm.allow_multi_user ' ) === true ) {
@@ -122,7 +118,7 @@ private function formatLocation($location, $type = null)
122
118
123
119
public function getPath ($ type = null )
124
120
{
125
- $ path = base_path () . '/ ' . Session:: get ( ' lfm. file_location' ) ;
121
+ $ path = base_path () . '/ ' . $ this -> file_location ;
126
122
127
123
$ path = $ this ->formatLocation ($ path , $ type );
128
124
@@ -132,7 +128,7 @@ public function getPath($type = null)
132
128
133
129
public function getUrl ($ type = null )
134
130
{
135
- $ url = Session:: get ( ' lfm. dir_location' ) ;
131
+ $ url = $ this -> dir_location ;
136
132
137
133
$ url = $ this ->formatLocation ($ url , $ type );
138
134
0 commit comments