jeudi 1 août 2019

Array to string conversion - Validation rule for eloquent

I am trying to validate a field using "in" and then passing an array befored defined. But when creating I get this error

"message": "Array to string conversion",
"exception": "ErrorException",

If I comment out the line where I use the validation, then works. So I am pretty sure the problem is that.

I've seen another related posts, but it didnt work.

Thank you.

CONST ARRAY_EXAMPLES = [
    'example1'  => 0,
    'example2'  => 1,
    'example3'   => 2,
    'example4'  => 3,
    'example5' => 4,
    'example6'  => 5,
];

protected $fillable = [
    'array_example'
];

'array_example' => 'int|in:' .array_values(self::ARRAY_EXAMPLES)



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire