mirror of
				https://github.com/pelican-dev/panel.git
				synced 2025-11-04 12:16:51 +01:00 
			
		
		
		
	
		
			
				
	
	
		
			34 lines
		
	
	
		
			826 B
		
	
	
	
		
			PHP
		
	
	
	
	
	
			
		
		
	
	
			34 lines
		
	
	
		
			826 B
		
	
	
	
		
			PHP
		
	
	
	
	
	
<?php
 | 
						|
 | 
						|
namespace App\Http\Requests\Admin;
 | 
						|
 | 
						|
use App\Models\Server;
 | 
						|
use Illuminate\Validation\Validator;
 | 
						|
 | 
						|
class ServerFormRequest extends AdminFormRequest
 | 
						|
{
 | 
						|
    /**
 | 
						|
     * Rules to be applied to this request.
 | 
						|
     */
 | 
						|
    public function rules(): array
 | 
						|
    {
 | 
						|
        $rules = Server::getRules();
 | 
						|
        $rules['description'][] = 'nullable';
 | 
						|
        $rules['custom_image'] = 'sometimes|nullable|string';
 | 
						|
 | 
						|
        return $rules;
 | 
						|
    }
 | 
						|
 | 
						|
    /**
 | 
						|
     * Run validation after the rules above have been applied.
 | 
						|
     */
 | 
						|
    public function withValidator(Validator $validator): void
 | 
						|
    {
 | 
						|
        $validator->after(function (Validator $validator) {
 | 
						|
            $validator->sometimes('node_id', 'required|numeric|bail|exists:nodes,id', function ($input) {
 | 
						|
                return !$input->auto_deploy;
 | 
						|
            });
 | 
						|
        });
 | 
						|
    }
 | 
						|
}
 |