|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace App\Imports; |
|
4
|
|
|
|
|
5
|
|
|
use Illuminate\Support\Collection; |
|
6
|
|
|
use App\Models\Examination_student; |
|
7
|
|
|
use Maatwebsite\Excel\Concerns\ToModel; |
|
8
|
|
|
use Maatwebsite\Excel\Concerns\Importable; |
|
9
|
|
|
use Maatwebsite\Excel\Concerns\ToCollection; |
|
10
|
|
|
use Maatwebsite\Excel\Concerns\WithStartRow; |
|
11
|
|
|
use Maatwebsite\Excel\Concerns\WithHeadingRow; |
|
12
|
|
|
use Maatwebsite\Excel\Concerns\WithBatchInserts; |
|
13
|
|
|
use Maatwebsite\Excel\Concerns\WithChunkReading; |
|
14
|
|
|
|
|
15
|
|
|
class ExaminationStudentsImport implements ToModel, WithStartRow, WithHeadingRow, WithChunkReading, WithBatchInserts |
|
16
|
|
|
{ |
|
17
|
|
|
use Importable; |
|
|
|
|
|
|
18
|
|
|
|
|
19
|
|
|
/** |
|
20
|
|
|
* @return int |
|
21
|
|
|
*/ |
|
22
|
|
|
public function startRow(): int |
|
23
|
|
|
{ |
|
24
|
|
|
return 2; |
|
25
|
|
|
} |
|
26
|
|
|
|
|
27
|
|
|
/** |
|
28
|
|
|
* @return int |
|
29
|
|
|
*/ |
|
30
|
|
|
public function headingRow(): int |
|
31
|
|
|
{ |
|
32
|
|
|
return 1; |
|
33
|
|
|
} |
|
34
|
|
|
|
|
35
|
|
|
public function chunkSize(): int |
|
36
|
|
|
{ |
|
37
|
|
|
return 10000; |
|
38
|
|
|
} |
|
39
|
|
|
|
|
40
|
|
|
public function batchSize(): int |
|
41
|
|
|
{ |
|
42
|
|
|
return 10000; |
|
43
|
|
|
} |
|
44
|
|
|
|
|
45
|
|
|
/** |
|
46
|
|
|
* @param Collection $collection |
|
47
|
|
|
*/ |
|
48
|
|
|
public function model(array $row) |
|
49
|
|
|
{ |
|
50
|
|
|
$insertData = array( |
|
51
|
|
|
'st_no' => $row['st_no'], |
|
52
|
|
|
'stu_no' => $row['stu_no'], |
|
53
|
|
|
"f_name" => $row['f_name'], |
|
54
|
|
|
"medium" => $row['medium'], |
|
55
|
|
|
"gender" => $row['gender'], |
|
56
|
|
|
"b_date" => $row['b_date'], |
|
57
|
|
|
"a_income" => $row['a_income'], |
|
58
|
|
|
"schoolid" => $row['schoolid'], |
|
59
|
|
|
"spl_need" => $row['spl_need'], |
|
60
|
|
|
"pvt_address" => $row['pvt_address'], |
|
61
|
|
|
"disability_type" => $row['disability_type'], |
|
62
|
|
|
"disability" => $row['disability'], |
|
63
|
|
|
"sp_center" => $row['sp_center'] |
|
64
|
|
|
); |
|
65
|
|
|
Examination_student::insertData($insertData); |
|
66
|
|
|
} |
|
67
|
|
|
} |
|
68
|
|
|
|