mirror of
https://gitlab.com/TheGamecraft/c-cms.git
synced 2026-04-25 20:29:10 -04:00
Include Vendor
This commit is contained in:
88
vendor/laravel/framework/src/Illuminate/Validation/ValidatesWhenResolvedTrait.php
vendored
Normal file
88
vendor/laravel/framework/src/Illuminate/Validation/ValidatesWhenResolvedTrait.php
vendored
Normal file
@@ -0,0 +1,88 @@
|
||||
<?php
|
||||
|
||||
namespace Illuminate\Validation;
|
||||
|
||||
/**
|
||||
* Provides default implementation of ValidatesWhenResolved contract.
|
||||
*/
|
||||
trait ValidatesWhenResolvedTrait
|
||||
{
|
||||
/**
|
||||
* Validate the class instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function validateResolved()
|
||||
{
|
||||
$this->prepareForValidation();
|
||||
|
||||
if (! $this->passesAuthorization()) {
|
||||
$this->failedAuthorization();
|
||||
}
|
||||
|
||||
$instance = $this->getValidatorInstance();
|
||||
|
||||
if (! $instance->passes()) {
|
||||
$this->failedValidation($instance);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepare the data for validation.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function prepareForValidation()
|
||||
{
|
||||
// no default action
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validator instance for the request.
|
||||
*
|
||||
* @return \Illuminate\Validation\Validator
|
||||
*/
|
||||
protected function getValidatorInstance()
|
||||
{
|
||||
return $this->validator();
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle a failed validation attempt.
|
||||
*
|
||||
* @param \Illuminate\Validation\Validator $validator
|
||||
* @return void
|
||||
*
|
||||
* @throws \Illuminate\Validation\ValidationException
|
||||
*/
|
||||
protected function failedValidation(Validator $validator)
|
||||
{
|
||||
throw new ValidationException($validator);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if the request passes the authorization check.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
protected function passesAuthorization()
|
||||
{
|
||||
if (method_exists($this, 'authorize')) {
|
||||
return $this->authorize();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle a failed authorization attempt.
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @throws \Illuminate\Validation\UnauthorizedException
|
||||
*/
|
||||
protected function failedAuthorization()
|
||||
{
|
||||
throw new UnauthorizedException;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user