123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 |
- <?php
- namespace App\Imports;
- use Carbon\Carbon;
- use Maatwebsite\Excel\Concerns\ToModel;
- use Maatwebsite\Excel\Concerns\Importable;
- use Maatwebsite\Excel\Concerns\SkipsOnError;
- use Maatwebsite\Excel\Concerns\SkipsEmptyRows;
- use Maatwebsite\Excel\Concerns\WithHeadingRow;
- use Maatwebsite\Excel\Concerns\WithBatchInserts;
- use Maatwebsite\Excel\Concerns\WithChunkReading;
- use Maatwebsite\Excel\Concerns\RemembersRowNumber;
- class CourseImport implements ToModel, SkipsOnError, WithHeadingRow, WithChunkReading, WithBatchInserts
- {
- use Importable, RemembersRowNumber;
- private $imported_list = [];
- public function model(array $row){
- $insertArray = [
- 'name' => $row['coursename'],
- 'institute' => $row['university'],
- 'campuses' => $row['campus'],
- 'level' => $row['level'],
- 'department' => $row['department'],
- 'length' => $row['courselength'],
- 'intakes' => $row['intake'],
- 'toefl' => $row['toefl'],
- 'ielts' => $row['ielts'],
- 'duolingo' => $row['duolingo'],
- 'pte' => $row['pte'],
- 'tuitionfee' => $row['tuitionfee'],
- 'scholarship' => $row['scholarship'],
- 'depositrequired' => $row['depositrequired'],
- 'reference' => $row['reference'],
- 'sop' => $row['sop'],
- 'cv' => $row['cv'],
- 'entryrequirement' => $row['entryrequirement'],
- 'tags' => $row['tags'],
- ];
- array_push($this->imported_list, $insertArray);
-
- }
- public function getImportedRows()
- {
- return $this->imported_list;
- }
- public function onError(\Throwable $e)
- {
- return res_msg('File import failed!', 403);
- }
- public function batchSize(): int
- {
- return 100;
- }
- public function chunkSize(): int
- {
- return 100;
- }
- }
|