I and trying to upload a CSV file and validate it against data types for each column. I am using Laravel-Excel 3.1 on Laravel 5.8.
I am allowing users to upload CSVs and as such the table is generated dynamically. I build an array for the validator (`$this->validator_array') that looks like this:
array:6 [▼
"*.0" => "date_format:d/m/Y|required"
"*.1" => "integer"
"*.2" => "date_format:d/m/Y"
"*.3" => "string"
"*.4" => "float|required"
"*.5" => "string|required"
]
Then in my Import class importing using collection, I call it like this:
/**
* Import CSV into collection
*
* @param Collection $rows
*/
public function collection(Collection $rows)
{
// Use Laravel to validate
Validator::make($rows->toArray(), [
$this->validator_array
])->validate();
foreach ($rows as $rowNum => $row)
{
// Only start import at desired row
if ($rowNum >= $this->start_import_row) {
// Format insert record
foreach($row as $colNum => $col) {
$this->formatted_row[$this->table_headings[$colNum]] = $col;
}
// Save record in table
DB::table($this->table_name)->insert($this->formatted_row);
}
}
}
But it fails with unrecongnized validation. My message is:
Method Illuminate\Validation\Validator::validateNumeric|required does not exist.
What did I miss?