I was trying to import csv file using Laravel-Excel 3.1. In the csv file have a date column and it's format is 'dd/mm/yy', example - "24/07/20". I am using ToModel method. How can I save intu the database in format of "yyyy/mm/dd", exaple - "2020/07/24". My code is as followed.
class DeviceDataImport implements ToModel, WithHeadingRow
{
private $counterNumber;
public function __construct($counterNumber)
{
HeadingRowFormatter::default('none');
$this->counter = $counterNumber;
}
public function model(array $row)
{
return new DeviceData([
'counter_id' => $this->counter,
'date' => $row['DATE'],
'amount' => $row['AMOUNT'
}
}