mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-14 07:02:34 +01:00
36 lines
792 B
PHP
36 lines
792 B
PHP
<?php
|
|
|
|
namespace App\Http\Requests;
|
|
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\Support\Facades\Validator;
|
|
|
|
trait RuntimeFormRequest
|
|
{
|
|
public static function runFormRequest($value)
|
|
{
|
|
$value = self::getMockedRequestByParameters($value);
|
|
|
|
$validator = self::createFrom($value, new self());
|
|
|
|
$validator->setContainer(app());
|
|
|
|
$validator->prepareForValidation();
|
|
|
|
$validator->setValidator(Validator::make($validator->all(), $validator->rules()));
|
|
|
|
$instance = $validator->getValidatorInstance();
|
|
|
|
return $instance;
|
|
}
|
|
|
|
|
|
protected static function getMockedRequestByParameters($paramters)
|
|
{
|
|
$mockRequest = Request::create('', 'POST');
|
|
|
|
$mockRequest->merge($paramters);
|
|
|
|
return $mockRequest;
|
|
}
|
|
} |