| Server IP : / Your IP : 10.244.4.16 [ Web Server : nginx/1.25.3 System : Linux escuela-portal-app-54f56585bc-kst6g 5.15.0-1084-azure #93-Ubuntu SMP Sat Mar 15 14:12:29 UTC 2025 x86_64 User : root ( 0) PHP Version : 8.2.13 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals, Domains : 0 Domains MySQL : OFF | cURL : ON | WGET : OFF | Perl : ON | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /proc/789/cwd/app/vendor/laravel/framework/src/Illuminate/Validation/ |
Upload File : |
<?php
namespace Illuminate\Validation;
use Illuminate\Support\Fluent;
class ConditionalRules
{
/**
* The boolean condition indicating if the rules should be added to the attribute.
*
* @var callable|bool
*/
protected $condition;
/**
* The rules to be added to the attribute.
*
* @var array|string|\Closure
*/
protected $rules;
/**
* The rules to be added to the attribute if the condition fails.
*
* @var array|string|\Closure
*/
protected $defaultRules;
/**
* Create a new conditional rules instance.
*
* @param callable|bool $condition
* @param array|string|\Closure $rules
* @param array|string|\Closure $defaultRules
* @return void
*/
public function __construct($condition, $rules, $defaultRules = [])
{
$this->condition = $condition;
$this->rules = $rules;
$this->defaultRules = $defaultRules;
}
/**
* Determine if the conditional rules should be added.
*
* @param array $data
* @return bool
*/
public function passes(array $data = [])
{
return is_callable($this->condition)
? call_user_func($this->condition, new Fluent($data))
: $this->condition;
}
/**
* Get the rules.
*
* @param array $data
* @return array
*/
public function rules(array $data = [])
{
return is_string($this->rules)
? explode('|', $this->rules)
: value($this->rules, new Fluent($data));
}
/**
* Get the default rules.
*
* @param array $data
* @return array
*/
public function defaultRules(array $data = [])
{
return is_string($this->defaultRules)
? explode('|', $this->defaultRules)
: value($this->defaultRules, new Fluent($data));
}
}