Closed vahidalvandi closed 5 years ago
You have to either upload the uploaded file to a disk or pass the uploaded file directly.
Example:
Excel::import(new importCommissionBatch($data->id), $request->file('import_file'));
thanks work fine but have another error
<?php
namespace App\excel;
use App\commission;
use Maatwebsite\Excel\Concerns\ToModel;
use Maatwebsite\Excel\Concerns\WithHeadingRow;
use Maatwebsite\Excel\Concerns\WithMultipleSheets;
use Jalalian;
use Maatwebsite\Excel\Facades\Excel;
use Webine\Base\Helpers\convert_date;
class importCommissionBatch implements ToModel,WithHeadingRow,WithMultipleSheets
{
protected $batch_id;
public function __construct($batch_id = 1)
{
$this->batch_id = $batch_id;
}
public function model(array $row)
{
if($row['amount'] && $row['user_id']) return new commission([
'batch_id'=>$this->batch_id,
'user_id'=>$row['user_id'],
'amount'=>$row['amount'],
'is_active'=>1,
'date_at'=>convert_date::to_gregorian($row['date_at_jalali']),
'date_jalali_at'=>$row['date_at_jalali'],
]);
}
public function sheets(): array
{
return [
// Select by sheet index
0 => new importCommissionBatch(),
];
}
}
Start row (2) is beyond highest row (1)
Start row (2) is beyond highest row (1)
Please read https://github.com/Maatwebsite/Laravel-Excel/issues/1889 and https://github.com/Maatwebsite/Laravel-Excel/issues/1904 first.
Might be something wrong with your file.
You have to either upload the uploaded file to a disk or pass the uploaded file directly.
Example:
Excel::import(new importCommissionBatch($data->id), $request->file('import_file'));
your solutions helps me a lot
Prerequisites
-->
Versions
Description
Hi
$path = $request->file('import_file')->getRealPath(); Excel::import(new importCommissionBatch($data->id), $path);
after use this code with upload file excel it returnLeague \ Flysystem \ FileNotFoundException File not found at path: D:/xampp/tmp/php4372.tmp
Steps to Reproduce
Expected behavior:
Actual behavior:
Additional Information
Any additional information, configuration or data that might be necessary to reproduce the issue.