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
8b70fdcb
Commit
8b70fdcb
authored
Sep 05, 2024
by
syaifurplus
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
insert dummy guru oke
parent
a666781f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
88 additions
and
2 deletions
+88
-2
ImportDapodikController.php
...Http/Controllers/Admin/Import/ImportDapodikController.php
+88
-2
No files found.
app/Http/Controllers/Admin/Import/ImportDapodikController.php
View file @
8b70fdcb
...
@@ -3,16 +3,102 @@
...
@@ -3,16 +3,102 @@
namespace
App\Http\Controllers\Admin\Import
;
namespace
App\Http\Controllers\Admin\Import
;
use
App\Http\Controllers\Controller
;
use
App\Http\Controllers\Controller
;
use
Illuminate\Http\Request
;
use
Illuminate\Http\Request
;
use
Illuminate\Support\Facades\DB
;
use
App\Models\Import\DapodikGuruModel
;
use
App\Models\Import\DapodikGuruModel
;
use
App\Models\Import\DapodikSiswaModel
;
use
App\Models\Import\DapodikSiswaModel
;
use
App\Models\User\UserModel
;
use
App\Models\Stakeholder\GuruModel
;
use
App\Models\Stakeholder\KonselorModel
;
use
App\Models\Perpus\SekolahModel
;
class
ImportDapodikController
extends
Controller
class
ImportDapodikController
extends
Controller
{
{
public
function
importDapodik
()
public
function
importDapodik
()
{
{
$dataGuru
=
DapodikGuruModel
::
get
();
$dataGuruTemp
=
DapodikGuruModel
::
select
([
'nama'
,
'nip'
,
'jenis_ptk'
,
'hp'
,
'email'
,
])
->
get
();
// echo json_encode($dataGuruTemp); die;
$importResults
=
[
'guru_mapel'
=>
[
'berhasil'
=>
0
,
'gagal'
=>
0
],
'guru_bk'
=>
[
'berhasil'
=>
0
,
'gagal'
=>
0
],
];
$dataGuruTemp
->
map
(
function
(
$guru
)
use
(
&
$importResults
)
{
// $existingGuru = GuruModel::where('nip', $guru->nip)->first();
$existingGuru
=
DB
::
table
(
'dummy_sekolah_guru'
)
->
where
(
'nip'
,
$guru
->
nip
)
->
first
();
if
(
$guru
->
jenis_ptk
==
'Guru Mapel'
)
{
if
(
!
$existingGuru
)
{
try
{
DB
::
table
(
'dummy_sekolah_guru'
)
->
insert
([
'idPSekolah'
=>
1
,
// dummy
'idMapel'
=>
99
,
'nip'
=>
$guru
->
nip
??
'-'
,
'telp'
=>
$guru
->
hp
??
'-'
,
'email'
=>
$guru
->
email
??
'-'
,
'status'
=>
1
,
]);
$importResults
[
'guru_mapel'
][
'berhasil'
]
++
;
}
catch
(
\Exception
$e
)
{
$importResults
[
'guru_mapel'
][
'gagal'
]
++
;
}
}
else
{
$importResults
[
'guru_mapel'
][
'gagal'
]
++
;
}
}
elseif
(
$guru
->
jenis_ptk
==
'Guru BK'
)
{
if
(
!
$existingGuru
)
{
try
{
$guruImport
=
DB
::
table
(
'dummy_sekolah_guru'
)
->
insertGetId
([
'idPSekolah'
=>
1
,
// dummy
'idMapel'
=>
99
,
'nip'
=>
$guru
->
nip
??
'-'
,
'telp'
=>
$guru
->
hp
??
'-'
,
'email'
=>
$guru
->
email
??
'-'
,
'status'
=>
1
,
]);
$konselorImport
=
DB
::
table
(
'dummy_sekolah_konselor'
)
->
insertGetId
([
'idPSekolah'
=>
1
,
// dummy
'idSGuru'
=>
$guruImport
,
'status'
=>
1
,
]);
$sekolah
=
SekolahModel
::
where
(
'id'
,
1
)
->
first
();
DB
::
table
(
'dummy_users'
)
->
insert
([
'username'
=>
$guru
->
email
,
'password'
=>
bcrypt
(
"sibiling-2024"
),
'sandi'
=>
"sibiling-2024"
,
// dummy
'status'
=>
1
,
'idPSekolah'
=>
1
,
// dummy
'role'
=>
3
,
// konselor
'idSKonselor'
=>
$konselorImport
,
'idPPeriode'
=>
$sekolah
->
idPPeriode
,
'telp'
=>
$guru
->
hp
??
'-'
,
]);
$importResults
[
'guru_bk'
][
'berhasil'
]
++
;
}
catch
(
\Exception
$e
)
{
$importResults
[
'guru_bk'
][
'gagal'
]
++
;
}
}
else
{
$importResults
[
'guru_bk'
][
'gagal'
]
++
;
}
}
});
echo
json_encode
(
$dataGuru
);
die
;
return
response
()
->
json
([
'message'
=>
'Proses import selesai'
,
'hasil'
=>
$importResults
,
]);
}
}
}
}
\ No newline at end of file
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