i wanna count the number of rows an imported file have
use a toModel type of import
Just keep a counter property in your import class.
namespace App\Imports;
use App\User;
use Maatwebsite\Excel\Concerns\ToModel;
class UsersImport implements ToModel
{
public $count = 0;
public function model(array $row)
{
++$this->count;
return new User([
'name' => $row[0],
]);
}
}
Most helpful comment
Just keep a counter property in your import class.