mirror of
				https://github.com/pelican-dev/panel.git
				synced 2025-10-31 05:46:51 +01:00 
			
		
		
		
	 aa08e774a1
			
		
	
	
		aa08e774a1
		
			
		
	
	
	
	
		
			
			* Add Nullable * Edit filament & AppServiceProvider * Pint * Patch tests * Actually patching tests * Actually patching tests * Remove length * Remove defaultStringLength * Let’s see the differences --------- Co-authored-by: Lance Pioch <git@lance.sh>
		
			
				
	
	
		
			41 lines
		
	
	
		
			1.3 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
			
		
		
	
	
			41 lines
		
	
	
		
			1.3 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
| <?php
 | |
| 
 | |
| namespace App\Http\Requests\Admin\Settings;
 | |
| 
 | |
| use Illuminate\Validation\Rule;
 | |
| use App\Http\Requests\Admin\AdminFormRequest;
 | |
| 
 | |
| class MailSettingsFormRequest extends AdminFormRequest
 | |
| {
 | |
|     /**
 | |
|      * Return rules to validate mail settings POST data against.
 | |
|      */
 | |
|     public function rules(): array
 | |
|     {
 | |
|         return [
 | |
|             'mail:mailers:smtp:host' => 'required|string',
 | |
|             'mail:mailers:smtp:port' => 'required|integer|between:1,65535',
 | |
|             'mail:mailers:smtp:encryption' => ['present', Rule::in([null, 'tls', 'ssl'])],
 | |
|             'mail:mailers:smtp:username' => 'nullable|string|max:255',
 | |
|             'mail:mailers:smtp:password' => 'nullable|string|max:255',
 | |
|             'mail:from:address' => 'required|string|email',
 | |
|             'mail:from:name' => 'nullable|string|max:255',
 | |
|         ];
 | |
|     }
 | |
| 
 | |
|     /**
 | |
|      * Override the default normalization function for this type of request
 | |
|      * as we need to accept empty values on the keys.
 | |
|      */
 | |
|     public function normalize(array $only = null): array
 | |
|     {
 | |
|         $keys = array_flip(array_keys($this->rules()));
 | |
| 
 | |
|         if (empty($this->input('mail:mailers:smtp:password'))) {
 | |
|             unset($keys['mail:mailers:smtp:password']);
 | |
|         }
 | |
| 
 | |
|         return $this->only(array_flip($keys));
 | |
|     }
 | |
| }
 |