I am trying to upload multiple files and everything is working except i cant figure out how to rename validation attribute of array request
Now i am getting (x can be any number as user can pick any number of files to upload )
The documents.x must be a file of type: png, gif, jpeg, txt, pdf, doc.
I would like to get (x starts with 0 so it has to be x + 1 )
The document x must be a file of type: png, gif, jpeg, txt, pdf, doc.
My Request
class CreatePersonRequest extends FormRequest
{
public function authorize()
{
return true;
}
public function rules()
{
$rules = [ 'name' => 'required|unique:people' ];
$docs = $this->file( 'documents' );
if ( !empty( $docs ) )
{
foreach ( $docs as $key => $doc )
{
$rules += ['documents.'.$key => 'mimes:png,gif,jpeg,txt,pdf,doc'] ;
}
}
return $rules;
}
public function attributes(){ //this isn't working
return [
'documents.*' => 'document/s',
];
}
}
I read that i have to do this in attributes but i cant figure out how. Any help is appricated