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;
from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/3aVna6C
via IFTTT
Aucun commentaire:
Enregistrer un commentaire