Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
sibiling
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
1
Issues
1
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Syaifur
sibiling
Commits
e9fa211c
Commit
e9fa211c
authored
Sep 05, 2024
by
Isa Asanu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
import data guru siswa
parent
65eaf5d7
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
279 additions
and
1 deletion
+279
-1
VerifyCsrfToken.php
app/Http/Middleware/VerifyCsrfToken.php
+3
-1
ImportDapodikGuru.php
app/Imports/ImportDapodikGuru.php
+90
-0
ImportDapodikSiswa.php
app/Imports/ImportDapodikSiswa.php
+113
-0
ImportDapodikGuruModel.php
app/Models/ImportDapodik/ImportDapodikGuruModel.php
+13
-0
ImportDapodikSiswaModel.php
app/Models/ImportDapodik/ImportDapodikSiswaModel.php
+13
-0
database.php
config/database.php
+20
-0
cobaimport.php
routes/cobaimport.php
+25
-0
web.php
routes/web.php
+2
-0
No files found.
app/Http/Middleware/VerifyCsrfToken.php
View file @
e9fa211c
...
@@ -13,5 +13,7 @@ class VerifyCsrfToken extends Middleware
...
@@ -13,5 +13,7 @@ class VerifyCsrfToken extends Middleware
*/
*/
protected
$except
=
[
protected
$except
=
[
//
//
// development only
'cobaimport/*'
];
];
}
}
app/Imports/ImportDapodikGuru.php
0 → 100644
View file @
e9fa211c
<?php
namespace
App\Imports
;
use
App\Models\ImportDapodik\ImportDapodikGuruModel
;
use
Illuminate\Support\Collection
;
use
Illuminate\Support\Facades\DB
;
use
Maatwebsite\Excel\Concerns\ToCollection
;
use
Maatwebsite\Excel\Concerns\WithHeadingRow
;
class
ImportDapodikGuru
implements
ToCollection
,
WithHeadingRow
{
// Skip rows before the actual table (adjust as needed)
public
function
headingRow
()
:
int
{
return
5
;
// Start reading from the second row (which contains the merged cells)
}
/**
* @param Collection $rows
*/
public
function
collection
(
Collection
$rows
)
{
// return
DB
::
beginTransaction
();
ini_set
(
"max_execution_time"
,
0
);
try
{
foreach
(
$rows
as
$row
)
{
ImportDapodikGuruModel
::
create
([
'nama'
=>
$row
[
'nama'
],
'nuptk'
=>
$row
[
'nuptk'
],
'jk'
=>
$row
[
'jk'
],
'tempat_lahir'
=>
$row
[
'tempat_lahir'
],
'tanggal_lahir'
=>
$row
[
'tanggal_lahir'
],
'nip'
=>
$row
[
'nip'
],
'status_kepegawaian'
=>
$row
[
'status_kepegawaian'
],
'jenis_ptk'
=>
$row
[
'jenis_ptk'
],
'agama'
=>
$row
[
'agama'
],
'alamat_jalan'
=>
$row
[
'alamat_jalan'
],
'rt'
=>
$row
[
'rt'
],
'rw'
=>
$row
[
'rw'
],
'nama_dusun'
=>
$row
[
'nama_dusun'
],
'desa_kelurahan'
=>
$row
[
'desakelurahan'
],
// Assuming 'desakelurahan' matches 'desa_kelurahan'
'kecamatan'
=>
$row
[
'kecamatan'
],
'kode_pos'
=>
$row
[
'kode_pos'
],
'telepon'
=>
$row
[
'telepon'
],
'hp'
=>
$row
[
'hp'
],
'email'
=>
$row
[
'email'
],
'tugas_tambahan'
=>
$row
[
'tugas_tambahan'
],
'sk_cpns'
=>
$row
[
'sk_cpns'
],
'tanggal_cpns'
=>
$row
[
'tanggal_cpns'
],
'sk_pengangkatan'
=>
$row
[
'sk_pengangkatan'
],
'tmt_pengangkatan'
=>
$row
[
'tmt_pengangkatan'
],
'lembaga_pengangkatan'
=>
$row
[
'lembaga_pengangkatan'
],
'pangkat_golongan'
=>
$row
[
'pangkat_golongan'
],
'sumber_gaji'
=>
$row
[
'sumber_gaji'
],
'nama_ibu_kandung'
=>
$row
[
'nama_ibu_kandung'
],
'status_perkawinan'
=>
$row
[
'status_perkawinan'
],
'nama_suami_istri'
=>
$row
[
'nama_suamiistri'
],
// Assuming 'nama_suamiistri' matches 'nama_suami_istri'
'nip_suami_istri'
=>
$row
[
'nip_suamiistri'
],
// Assuming 'nip_suamiistri' matches 'nip_suami_istri'
'pekerjaan_suami_istri'
=>
$row
[
'pekerjaan_suamiistri'
],
// Assuming 'pekerjaan_suamiistri' matches 'pekerjaan_suami_istri'
'tmt_pns'
=>
$row
[
'tmt_pns'
],
'sudah_lisensi_kepala_sekolah'
=>
$row
[
'sudah_lisensi_kepala_sekolah'
],
'pernah_diklat_kepengawasan'
=>
$row
[
'pernah_diklat_kepengawasan'
],
'keahlian_braille'
=>
$row
[
'keahlian_braille'
],
'keahlian_bahasa_isyarat'
=>
$row
[
'keahlian_bahasa_isyarat'
],
'npwp'
=>
$row
[
'npwp'
],
'nama_wajib_pajak'
=>
$row
[
'nama_wajib_pajak'
],
'kewarganegaraan'
=>
$row
[
'kewarganegaraan'
],
'bank'
=>
$row
[
'bank'
],
'nomor_rekening_bank'
=>
$row
[
'nomor_rekening_bank'
],
'rekening_atas_nama'
=>
$row
[
'rekening_atas_nama'
],
'nik'
=>
$row
[
'nik'
],
'no_kk'
=>
$row
[
'no_kk'
],
'karpeg'
=>
$row
[
'karpeg'
],
'karis_karsu'
=>
$row
[
'kariskarsu'
],
'lintang'
=>
$row
[
'lintang'
],
'bujur'
=>
$row
[
'bujur'
],
'nuks'
=>
$row
[
'nuks'
],
]);
}
DB
::
commit
();
}
catch
(
\Exception
$e
)
{
// Rollback the transaction
DB
::
rollBack
();
// Handle the exception and return a response
throw
$e
;
}
}
}
app/Imports/ImportDapodikSiswa.php
0 → 100644
View file @
e9fa211c
<?php
namespace
App\Imports
;
use
Illuminate\Support\Facades\DB
;
use
App\Models\ImportDapodik\ImportDapodikSiswaModel
;
use
Illuminate\Support\Collection
;
use
Maatwebsite\Excel\Concerns\ToCollection
;
use
Maatwebsite\Excel\Concerns\WithHeadingRow
;
class
ImportDapodikSiswa
implements
ToCollection
,
WithHeadingRow
{
// Skip rows before the actual table (adjust as needed)
public
function
headingRow
()
:
int
{
return
5
;
// Start reading from the second row (which contains the merged cells)
}
/**
* @param Collection $rows
*/
public
function
collection
(
Collection
$rows
)
{
$rows
->
shift
();
DB
::
beginTransaction
();
ini_set
(
"max_execution_time"
,
0
);
try
{
foreach
(
$rows
as
$row
)
{
ImportDapodikSiswaModel
::
create
([
'nama'
=>
$row
[
'nama'
],
'nipd'
=>
$row
[
'nipd'
],
'jk'
=>
$row
[
'jk'
],
'nisn'
=>
$row
[
'nisn'
],
'tempat_lahir'
=>
$row
[
'tempat_lahir'
],
'tanggal_lahir'
=>
$row
[
'tanggal_lahir'
],
'nik'
=>
$row
[
'nik'
],
'agama'
=>
$row
[
'agama'
],
'alamat'
=>
$row
[
'alamat'
],
'rt'
=>
$row
[
'rt'
],
'rw'
=>
$row
[
'rw'
],
'dusun'
=>
$row
[
'dusun'
],
'kelurahan'
=>
$row
[
'kelurahan'
],
'kecamatan'
=>
$row
[
'kecamatan'
],
'kode_pos'
=>
$row
[
'kode_pos'
],
'jenis_tinggal'
=>
$row
[
'jenis_tinggal'
],
'alat_transportasi'
=>
$row
[
'alat_transportasi'
],
'telepon'
=>
$row
[
'telepon'
],
'hp'
=>
$row
[
'hp'
],
'email'
=>
$row
[
'e_mail'
],
'skhun'
=>
$row
[
'skhun'
],
'penerima_kps'
=>
$row
[
'penerima_kps'
],
'no_kps'
=>
$row
[
'no_kps'
],
// Data Ayah
'nama_ayah'
=>
$row
[
'data_ayah'
],
'tahun_lahir_ayah'
=>
$row
[
25
],
'jenjang_pendidikan_ayah'
=>
$row
[
26
],
'pekerjaan_ayah'
=>
$row
[
27
],
'penghasilan_ayah'
=>
$row
[
28
],
'nik_ayah'
=>
$row
[
29
],
// Data Ibu
'nama_ibu'
=>
$row
[
'data_ibu'
],
'tahun_lahir_ibu'
=>
$row
[
31
],
'jenjang_pendidikan_ibu'
=>
$row
[
32
],
'pekerjaan_ibu'
=>
$row
[
33
],
'penghasilan_ibu'
=>
$row
[
34
],
'nik_ibu'
=>
$row
[
35
],
// Data Wali
'nama_wali'
=>
$row
[
'data_wali'
],
'tahun_lahir_wali'
=>
$row
[
37
],
'jenjang_pendidikan_wali'
=>
$row
[
38
],
'pekerjaan_wali'
=>
$row
[
39
],
'penghasilan_wali'
=>
$row
[
40
],
'nik_wali'
=>
$row
[
41
],
'rombel_saat_ini'
=>
$row
[
'rombel_saat_ini'
],
'no_peserta_un'
=>
$row
[
'no_peserta_ujian_nasional'
],
'no_seri_ijazah'
=>
$row
[
'no_seri_ijazah'
],
'penerima_kip'
=>
$row
[
'penerima_kip'
],
'nomor_kip'
=>
$row
[
'nomor_kip'
],
'nama_di_kip'
=>
$row
[
'nama_di_kip'
],
'nomor_kks'
=>
$row
[
'nomor_kks'
],
'no_registrasi_akta_lahir'
=>
$row
[
'no_registrasi_akta_lahir'
],
'bank'
=>
$row
[
'bank'
],
'nomor_rekening_bank'
=>
$row
[
'nomor_rekening_bank'
],
'rekening_atas_nama'
=>
$row
[
'rekening_atas_nama'
],
'layak_pip'
=>
$row
[
'layak_pip_usulan_dari_sekolah'
],
'alasan_layak_pip'
=>
$row
[
'alasan_layak_pip'
],
'kebutuhan_khusus'
=>
$row
[
'kebutuhan_khusus'
],
'sekolah_asal'
=>
$row
[
'sekolah_asal'
],
'anak_keberapa'
=>
$row
[
'anak_ke_berapa'
],
'lintang'
=>
$row
[
'lintang'
],
'bujur'
=>
$row
[
'bujur'
],
'no_kk'
=>
$row
[
'no_kk'
],
'berat_badan'
=>
$row
[
'berat_badan'
],
'tinggi_badan'
=>
$row
[
'tinggi_badan'
],
'lingkar_kepala'
=>
$row
[
'lingkar_kepala'
],
'jml_saudara_kandung'
=>
$row
[
'jml_saudara_kandung'
],
'jarak_rumah_ke_sekolah_km'
=>
$row
[
'jarak_rumah_ke_sekolah_km'
]
]);
}
DB
::
commit
();
}
catch
(
\Exception
$e
)
{
// Rollback the transaction
DB
::
rollBack
();
// Handle the exception and return a response
throw
$e
;
}
}
}
app/Models/ImportDapodik/ImportDapodikGuruModel.php
0 → 100644
View file @
e9fa211c
<?php
namespace
App\Models\ImportDapodik
;
use
Illuminate\Database\Eloquent\Model
;
class
ImportDapodikGuruModel
extends
Model
{
// Nama tabel
protected
$connection
=
'datatemp'
;
protected
$table
=
'data_guru'
;
protected
$guarded
=
[];
}
app/Models/ImportDapodik/ImportDapodikSiswaModel.php
0 → 100644
View file @
e9fa211c
<?php
namespace
App\Models\ImportDapodik
;
use
Illuminate\Database\Eloquent\Model
;
class
ImportDapodikSiswaModel
extends
Model
{
// Nama tabel
protected
$connection
=
'datatemp'
;
protected
$table
=
'data_peserta_didik'
;
protected
$guarded
=
[];
}
config/database.php
View file @
e9fa211c
...
@@ -63,6 +63,26 @@ return [
...
@@ -63,6 +63,26 @@ return [
])
:
[],
])
:
[],
],
],
'datatemp'
=>
[
'driver'
=>
'mysql'
,
'url'
=>
env
(
'DATABASE_URL'
),
'host'
=>
env
(
'DB_HOST'
,
'127.0.0.1'
),
'port'
=>
env
(
'DB_PORT'
,
'3306'
),
'database'
=>
env
(
'DB_DATABASE_DATATEMP'
,
'forge'
),
'username'
=>
env
(
'DB_USERNAME'
,
'forge'
),
'password'
=>
env
(
'DB_PASSWORD'
,
''
),
'unix_socket'
=>
env
(
'DB_SOCKET'
,
''
),
'charset'
=>
'utf8mb4'
,
'collation'
=>
'utf8mb4_unicode_ci'
,
'prefix'
=>
''
,
'prefix_indexes'
=>
true
,
'strict'
=>
true
,
'engine'
=>
null
,
'options'
=>
extension_loaded
(
'pdo_mysql'
)
?
array_filter
([
PDO
::
MYSQL_ATTR_SSL_CA
=>
env
(
'MYSQL_ATTR_SSL_CA'
),
])
:
[],
],
'pgsql'
=>
[
'pgsql'
=>
[
'driver'
=>
'pgsql'
,
'driver'
=>
'pgsql'
,
'url'
=>
env
(
'DATABASE_URL'
),
'url'
=>
env
(
'DATABASE_URL'
),
...
...
routes/cobaimport.php
0 → 100644
View file @
e9fa211c
<?php
use
App\Imports\ImportDapodikGuru
;
use
App\Imports\ImportDapodikSiswa
;
use
Illuminate\Http\Request
;
use
Illuminate\Support\Facades\Route
;
use
Maatwebsite\Excel\Facades\Excel
;
Route
::
post
(
'/cobaimport/dataguru'
,
function
(
Request
$request
){
try
{
Excel
::
import
(
new
ImportDapodikGuru
,
$request
->
file
(
'file'
));
return
response
()
->
json
([
'message'
=>
'Success'
]);
}
catch
(
\Exception
$e
){
return
response
()
->
json
([
'error'
=>
'Failed to create model: '
.
$e
->
getMessage
()],
500
);
}
});
Route
::
post
(
'/cobaimport/datasiswa'
,
function
(
Request
$request
){
try
{
Excel
::
import
(
new
ImportDapodikSiswa
,
$request
->
file
(
'file'
));
return
response
()
->
json
([
'message'
=>
'Success'
]);
}
catch
(
\Exception
$e
){
return
response
()
->
json
([
'error'
=>
'Failed to create model: '
.
$e
->
getMessage
()],
500
);
}
});
\ No newline at end of file
routes/web.php
View file @
e9fa211c
...
@@ -2,6 +2,8 @@
...
@@ -2,6 +2,8 @@
use
Illuminate\Support\Facades\Route
;
use
Illuminate\Support\Facades\Route
;
require
__DIR__
.
'/cobaimport.php'
;
/*
/*
|--------------------------------------------------------------------------
|--------------------------------------------------------------------------
| Web Routes
| Web Routes
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment