66use Illuminate \Support \Facades \Input ;
77use Illuminate \Support \Facades \Redirect ;
88
9- class ProfilePhotoUploadController extends Controller
9+ class ProfilePhotoController extends Controller
1010{
1111
1212 public function index (Request $ request )
@@ -26,12 +26,12 @@ private static function getUploadDirectory()
2626 private static function getProfilePhotoPath ()
2727 {
2828 $ user = BaseUser::getDbUser ();
29- return ProfilePhotoUploadController ::getUploadDirectory () . 'user_ ' . $ user ->id . '.jpg ' ;
29+ return ProfilePhotoController ::getUploadDirectory () . 'user_ ' . $ user ->id . '.jpg ' ;
3030 }
3131
3232 public static function hasProfilePhoto ()
3333 {
34- return file_exists (ProfilePhotoUploadController ::getProfilePhotoPath ());
34+ return file_exists (ProfilePhotoController ::getProfilePhotoPath ());
3535 }
3636
3737 /**
@@ -60,7 +60,7 @@ private static function getFileNameFromOriginalName(string $user_id, string $ori
6060 public function photo ()
6161 {
6262 if (BaseUser::isSignedIn ()) {
63- $ file_path = ProfilePhotoUploadController ::getProfilePhotoPath ();
63+ $ file_path = ProfilePhotoController ::getProfilePhotoPath ();
6464 return response ()->file ($ file_path );
6565 } else {
6666 return redirect ()->intended ('signin ' );
@@ -88,15 +88,15 @@ private static function getPhotoDimensionsFromUploadDimensions($width, $height)
8888
8989 public static function save ($ image )
9090 {
91- $ destinationPath = ProfilePhotoUploadController ::getUploadDirectory ();
91+ $ destinationPath = ProfilePhotoController ::getUploadDirectory ();
9292
9393 $ user = BaseUser::getDbUser ();
9494
9595 $ full_path = $ destinationPath . 'user_ ' . $ user ->id . '.jpg ' ;
9696
9797 $ width = imagesx ($ image );
9898 $ height = imagesy ($ image );
99- $ newDimensions = ProfilePhotoUploadController ::getPhotoDimensionsFromUploadDimensions ($ width , $ height );
99+ $ newDimensions = ProfilePhotoController ::getPhotoDimensionsFromUploadDimensions ($ width , $ height );
100100
101101 // png images can be transparent and the transparent areas are defaulted to black.
102102 // We want the background to default to white.
@@ -129,15 +129,15 @@ public function post(Request $request)
129129 $ content = file_get_contents ($ temp_filename );
130130 $ new_image = imagecreatefromstring ($ content );
131131
132- return ProfilePhotoUploadController ::save ($ new_image );
132+ return ProfilePhotoController ::save ($ new_image );
133133 } else {
134134 return redirect ()->intended ('signin ' );
135135 }
136136 }
137137
138138 public function delete ()
139139 {
140- $ file = ProfilePhotoUploadController ::getProfilePhotoPath ();
140+ $ file = ProfilePhotoController ::getProfilePhotoPath ();
141141 if (!unlink ($ file )) {
142142 echo ("Error deleting $ file " );
143143 } else {
@@ -148,12 +148,12 @@ public function delete()
148148 // Rotate Profile Photo
149149 public function rotate ()
150150 {
151- $ current_photo = ProfilePhotoUploadController ::getProfilePhotoPath ();
151+ $ current_photo = ProfilePhotoController ::getProfilePhotoPath ();
152152
153153 $ content = file_get_contents ($ current_photo );
154154 $ image = imagecreatefromstring ($ content );
155155
156156 $ new_image = imagerotate ($ image , -90 , 0 );
157- return ProfilePhotoUploadController ::save ($ new_image );
157+ return ProfilePhotoController ::save ($ new_image );
158158 }
159159}
0 commit comments