26 lines
537 B
PHP
26 lines
537 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Tests\Classes;
|
|
|
|
use Icefox\DTO\DataObject;
|
|
use Illuminate\Http\Exceptions\HttpResponseException;
|
|
use Illuminate\Validation\Validator;
|
|
|
|
readonly class FailsWithHttpResponse
|
|
{
|
|
use DataObject;
|
|
|
|
public function __construct(
|
|
public string $string,
|
|
public int $int,
|
|
) {}
|
|
|
|
public static function fails(Validator $validator): ?static
|
|
{
|
|
throw new HttpResponseException(
|
|
response()->json(['errors' => $validator->errors()], 422)
|
|
);
|
|
}
|
|
}
|