1 | <?php |
||
8 | class BantenprovZonaSeeder extends Seeder |
||
|
|||
9 | { |
||
10 | /* text color */ |
||
11 | protected $RED ="\033[0;31m"; |
||
12 | protected $CYAN ="\033[0;36m"; |
||
13 | protected $YELLOW ="\033[1;33m"; |
||
14 | protected $ORANGE ="\033[0;33m"; |
||
15 | protected $PUR ="\033[0;35m"; |
||
16 | protected $GRN ="\e[32m"; |
||
17 | protected $WHI ="\e[37m"; |
||
18 | protected $NC ="\033[0m"; |
||
19 | /* File name */ |
||
20 | /* location : /databse/seeds/file_name.csv */ |
||
21 | protected $fileName = "BantenprovZonaSeeder.csv"; |
||
22 | /* text info : default (true) */ |
||
23 | protected $textInfo = true; |
||
24 | /* model class */ |
||
25 | protected $model; |
||
26 | /* __construct */ |
||
27 | public function __construct(){ |
||
28 | $this->model = new Bantenprov\Zona\Models\Bantenprov\Zona\Zona; |
||
29 | } |
||
30 | /** |
||
31 | * Run the database seeds. |
||
32 | * |
||
33 | * @return void |
||
34 | */ |
||
35 | public function run() |
||
36 | { |
||
37 | $this->insertData(); |
||
38 | } |
||
39 | /* function insert data */ |
||
40 | protected function insertData() |
||
41 | { |
||
42 | /* silahkan di rubah sesuai kebutuhan */ |
||
43 | foreach($this->readCSV() as $data){ |
||
44 | |||
45 | |||
46 | $this->model->create([ |
||
47 | 'user_id' => $data['user_id'], |
||
48 | 'master_zona_id' => $data['master_zona_id'], |
||
49 | 'siswa_id' => $data['siswa_id'], |
||
50 | 'nomor_un' => $data['nomor_un'], |
||
51 | 'zona_siswa' => $data['zona_siswa'], |
||
52 | 'zona_sekolah' => $data['zona_sekolah'], |
||
53 | 'lokasi_siswa' => $data['lokasi_siswa'], |
||
54 | 'lokasi_sekolah' => $data['lokasi_sekolah'], |
||
55 | 'nilai_zona' => $data['nilai_zona'], |
||
56 | |||
57 | ]); |
||
58 | |||
59 | |||
60 | } |
||
61 | |||
62 | if($this->textInfo){ |
||
63 | echo "============[DATA]============\n"; |
||
64 | $this->orangeText('user_id : ').$this->greenText($data['user_id']); |
||
65 | echo"\n"; |
||
66 | $this->orangeText('master_zona_id : ').$this->greenText($data['master_zona_id']); |
||
67 | echo"\n"; |
||
68 | $this->orangeText('siswa_id : ').$this->greenText($data['siswa_id']); |
||
69 | echo"\n"; |
||
70 | $this->orangeText('nomor_un : ').$this->greenText($data['nomor_un']); |
||
71 | echo"\n"; |
||
72 | this->orangeText('zona_siswa : ').$this->greenText($data['zona_siswa']); |
||
73 | echo"\n"; |
||
74 | this->orangeText('zona_sekolah : ').$this->greenText($data['zona_sekolah']); |
||
75 | echo"\n"; |
||
76 | this->orangeText('lokasi_siswa : ').$this->greenText($data['lokasi_siswa']); |
||
77 | echo"\n"; |
||
78 | this->orangeText('lokasi_sekolah : ').$this->greenText($data['lokasi_sekolah']); |
||
79 | echo"\n"; |
||
80 | this->orangeText('nilai_zona : ').$this->greenText($data['nilai_zona']); |
||
81 | echo"\n"; |
||
82 | |||
83 | |||
84 | |||
85 | |||
86 | echo "============[DATA]============\n\n"; |
||
87 | } |
||
88 | |||
89 | $this->greenText('[ SEEDER DONE ]'); |
||
90 | echo"\n\n"; |
||
91 | } |
||
92 | /* text color: orange */ |
||
93 | protected function orangeText($text) |
||
94 | { |
||
95 | printf($this->ORANGE.$text.$this->NC); |
||
96 | } |
||
97 | /* text color: green */ |
||
124 |
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.