Test Setup Failed
Push — master ( 93675a...ba3342 )
by Mohamed
14:07 queued 12s
created

ExaminationStudentsImport   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 51
Duplicated Lines 0 %

Importance

Changes 3
Bugs 0 Features 1
Metric Value
eloc 21
dl 0
loc 51
rs 10
c 3
b 0
f 1
wmc 5

5 Methods

Rating   Name   Duplication   Size   Complexity  
A startRow() 0 3 1
A batchSize() 0 3 1
A chunkSize() 0 3 1
A model() 0 18 1
A headingRow() 0 3 1
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;
0 ignored issues
show
introduced by
The trait Maatwebsite\Excel\Concerns\Importable requires some properties which are not provided by App\Imports\ExaminationStudentsImport: $disk, $readerType, $filePath
Loading history...
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