Path: blob/1.0-develop/app/Exceptions/Model/DataValidationException.php
10279 views
<?php12namespace Pterodactyl\Exceptions\Model;34use Illuminate\Support\MessageBag;5use Illuminate\Database\Eloquent\Model;6use Illuminate\Contracts\Validation\Validator;7use Pterodactyl\Exceptions\PterodactylException;8use Illuminate\Contracts\Support\MessageProvider;9use Symfony\Component\HttpKernel\Exception\HttpExceptionInterface;1011class DataValidationException extends PterodactylException implements HttpExceptionInterface, MessageProvider12{13/**14* DataValidationException constructor.15*/16public function __construct(protected Validator $validator, protected Model $model)17{18$message = sprintf(19'Could not save %s[%s]: failed to validate data: %s',20get_class($model),21$model->getKey(),22$validator->errors()->toJson()23);2425parent::__construct($message);26}2728/**29* Return the validator message bag.30*/31public function getMessageBag(): MessageBag32{33return $this->validator->errors();34}3536/**37* Return the status code for this request.38*/39public function getStatusCode(): int40{41return 500;42}4344public function getHeaders(): array45{46return [];47}4849public function getValidator(): Validator50{51return $this->validator;52}5354public function getModel(): Model55{56return $this->model;57}58}596061