How to format field names in the output of Laravel validation messages?

0

I'm using $this->validate() to perform field validation in Laravel, how can I automatically underline the field name in the output of all valid validation error messages?

I'm using Laravel 5.6

    
asked by anonymous 15.03.2018 / 04:16

1 answer

0

You can use the OutputFormatterStyle class and the methods getFormatter and setStyle

Example:

   use Symfony\Component\Console\Formatter\OutputFormatterStyle;

   // ...

   function OutputHandler($sua_ saida)
   {
        $style = new OutputFormatterStyle('white', array('underscore'));
        $this->command->output->getFormatter()->setStyle('underscored', $style);

       $this->command->output->writeln('<underscored>'.$sua_ saida.'</underscored>');
    }

Put it inside a model, and always use the handler to give the output you need to put the underline:

$class = new ClasseQueRepresentar();
$class->OutputHandler('algo');

Source: link

    
15.03.2018 / 05:03