lundi 28 décembre 2020

Matwebexcel getRowCount returns 0

I tried the following code following document: https://docs.laravel-excel.com/3.1/architecture/objects.html#getters

        class CategoryImport implements ToModel, WithHeadingRow, WithMultipleSheets
        {
            use SkipsFailures, Importable;
    
        private $rows = 0;
    ------

 

         public function model(array $row)
            {
            ++$this->rows;// get row count

            $this->application = (new Application());    
            $this->application->category_id = $cate_id;//
            $this->application->save();
}

public function getRowCount():int
{
    return $this->rows;
}

Call:

$import = (new CategoryImport($request, $org_file_name));
            $data = Excel::import($import, storage_path('file') . '/' . $fileName);
            $total = $import->getRowCount();

$total always returns 0;



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire