mirror of
				https://github.com/linuxserver/Heimdall.git
				synced 2025-11-01 05:27:45 +09:00 
			
		
		
		
	fix: Add more verbose error when uploading background image (#1082)
This commit is contained in:
		| @@ -4,6 +4,7 @@ namespace App\Http\Controllers; | |||||||
|  |  | ||||||
| use App\Setting; | use App\Setting; | ||||||
| use App\SettingGroup; | use App\SettingGroup; | ||||||
|  | use Exception; | ||||||
| use Illuminate\Contracts\View\View; | use Illuminate\Contracts\View\View; | ||||||
| use Illuminate\Http\RedirectResponse; | use Illuminate\Http\RedirectResponse; | ||||||
| use Illuminate\Http\Request; | use Illuminate\Http\Request; | ||||||
| @@ -53,7 +54,7 @@ class SettingsController extends Controller | |||||||
|  |  | ||||||
|             return redirect($route) |             return redirect($route) | ||||||
|             ->with([ |             ->with([ | ||||||
|                 'error' => __('app.alert.error.not_exist'), |                 'errors' => collect([__('app.alert.error.not_exist')]), | ||||||
|             ]); |             ]); | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
| @@ -68,37 +69,44 @@ class SettingsController extends Controller | |||||||
|     { |     { | ||||||
|         $setting = Setting::find($id); |         $setting = Setting::find($id); | ||||||
|         $user = $this->user(); |         $user = $this->user(); | ||||||
|  |         $route = route('settings.index', []); | ||||||
|  |  | ||||||
|         if (! is_null($setting)) { |         try { | ||||||
|             $data = Setting::getInput($request); |             if (is_null($setting)) { | ||||||
|  |                 throw new Exception('not_exists'); | ||||||
|  |             } | ||||||
|  |  | ||||||
|             $setting_value = null; |             if ($setting->type === 'image') { | ||||||
|  |                 if (!$request->hasFile('value')) { | ||||||
|             if ($setting->type == 'image') { |                     throw new \Exception( | ||||||
|                 if ($request->hasFile('value')) { |                         'file_too_big' | ||||||
|                     $path = $request->file('value')->store('backgrounds'); |                     ); | ||||||
|                     $setting_value = $path; |  | ||||||
|                 } |                 } | ||||||
|  |  | ||||||
|  |                 $path = $request->file('value')->store('backgrounds'); | ||||||
|  |  | ||||||
|  |                 if ($path === null) { | ||||||
|  |                     throw new \Exception('file_not_stored'); | ||||||
|  |                 } | ||||||
|  |  | ||||||
|  |                 $setting_value = $path; | ||||||
|             } else { |             } else { | ||||||
|  |                 $data = Setting::getInput($request); | ||||||
|                 $setting_value = $data->value; |                 $setting_value = $data->value; | ||||||
|             } |             } | ||||||
|  |  | ||||||
|             $user->settings()->detach($setting->id); |             $user->settings()->detach($setting->id); | ||||||
|             $user->settings()->save($setting, ['uservalue' => $setting_value]); |             $user->settings()->save($setting, ['uservalue' => $setting_value]); | ||||||
|  |  | ||||||
|             $route = route('settings.index', []); |  | ||||||
|  |  | ||||||
|             return redirect($route) |             return redirect($route) | ||||||
|             ->with([ |                 ->with([ | ||||||
|                 'success' => __('app.alert.success.setting_updated'), |                     'success' => __('app.alert.success.setting_updated'), | ||||||
|             ]); |                 ]); | ||||||
|         } else { |         } catch (Exception $e) { | ||||||
|             $route = route('settings.index', []); |  | ||||||
|  |  | ||||||
|             return redirect($route) |             return redirect($route) | ||||||
|             ->with([ |                 ->with([ | ||||||
|                 'error' => __('app.alert.error.not_exist'), |                     'errors' => collect([__('app.alert.error.'.$e->getMessage())]), | ||||||
|             ]); |                 ]); | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  |  | ||||||
|   | |||||||
| @@ -100,6 +100,8 @@ return array ( | |||||||
|   'alert.success.tag_restored' => 'Tag restored successfully', |   'alert.success.tag_restored' => 'Tag restored successfully', | ||||||
|   'alert.success.setting_updated' => 'You have successfully edited this setting', |   'alert.success.setting_updated' => 'You have successfully edited this setting', | ||||||
|   'alert.error.not_exist' => 'This setting does not exist.', |   'alert.error.not_exist' => 'This setting does not exist.', | ||||||
|  |   'alert.error.file_too_big' => 'File is too big.', | ||||||
|  |   'alert.error.file_not_stored' => 'File could not be stored.', | ||||||
|   'alert.success.user_created' => 'User created successfully', |   'alert.success.user_created' => 'User created successfully', | ||||||
|   'alert.success.user_updated' => 'User updated successfully', |   'alert.success.user_updated' => 'User updated successfully', | ||||||
|   'alert.success.user_deleted' => 'User deleted successfully', |   'alert.success.user_deleted' => 'User deleted successfully', | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user