Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
3
3f-timesheet
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
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
dockers
3f-timesheet
Commits
22cfe6af
Commit
22cfe6af
authored
Jun 11, 2025
by
zeecostorage
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
sync user
parent
717543df
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
64 additions
and
3 deletions
+64
-3
packages/portal/timesheet/src/Http/Controllers/UsersController.php
+64
-3
No files found.
packages/portal/timesheet/src/Http/Controllers/UsersController.php
View file @
22cfe6af
...
...
@@ -23,6 +23,9 @@ use App\Mail\StatusReject;
use
Mail
;
use
Curl
;
use
Auth
;
use
App\User
as
Users
;
use
Portal\Timesheet\Model\Urole
as
Aclrole
;
use
Portal\Timesheet\Model\Staff_info
as
StaffInfo
;
use
Illuminate\Support\Facades\Artisan
;
...
...
@@ -38,10 +41,68 @@ class UsersController extends Controller
public
function
syncNewUsers
()
{
// Run command manual
$output
=
shell_exec
(
'php /www/html/timesheet3f/artisan migrate:user-cron 2>&1'
);
//
$output = shell_exec('php /www/html/timesheet3f/artisan migrate:user-cron 2>&1');
// Log the output for debugging
\Log
::
info
(
"migrate:user-cron output: "
.
$output
);
// // Log the output for debugging
// \Log::info("migrate:user-cron output: " . $output);
$migrateuser
=
DB
::
connection
(
'mysql'
)
->
table
(
'migrate_user'
)
->
where
(
'id'
,
1
)
->
first
();
// dump($migrateuser);
$user
=
DB
::
connection
(
'mysql2'
)
->
table
(
'users'
)
->
join
(
'staff_info'
,
'staff_info.fk_users'
,
'='
,
'users.id'
)
->
where
(
'users.id'
,
'>'
,
$migrateuser
->
userid
)
->
select
(
'users.id'
,
'users.email'
,
'users.fullname'
,
'users.staff_id'
,
'staff_info.fk_lkp_country'
,
'staff_info.fk_lkp_state'
,
'staff_info.ic_no'
,
'staff_info.email'
)
->
get
();
// dd($user);
if
(
$user
){
foreach
(
$user
as
$key
=>
$value
){
$new
=
new
Users
;
$new
->
name
=
strtoupper
(
$value
->
fullname
);
$new
->
email
=
$value
->
email
;
$new
->
status
=
'ACTIVE'
;
$new
->
timezone
=
'UTC'
;
$new
->
meta
=
NULL
;
$new
->
email_verified_at
=
NULL
;
$new
->
password
=
'$2y$10$TKh8H1.PfQx37YgCzwiKb.KjNyWgaHb9cbcoQgdIVFlYg7B77UdFm'
;
//secret
$new
->
password_last_set
=
NULL
;
$new
->
u_staffID
=
$value
->
staff_id
;
$new
->
save
();
$role
=
new
Aclrole
;
$role
->
user_id
=
$new
->
id
;
$role
->
role_id
=
5
;
$role
->
save
();
$saveinfo
=
new
StaffInfo
;
$saveinfo
->
fk_lkp_country
=
$value
->
fk_lkp_country
;
$saveinfo
->
fk_lkp_state
=
$value
->
fk_lkp_state
;
$saveinfo
->
fk_users
=
$new
->
id
;
$saveinfo
->
ic_no
=
$value
->
ic_no
;
$saveinfo
->
email
=
$value
->
email
;
$saveinfo
->
staff_id
=
$value
->
staff_id
;
$saveinfo
->
fullname
=
strtoupper
(
$value
->
fullname
);
$saveinfo
->
status
=
1
;
$saveinfo
->
save
();
//update migrate user
$updmigrate
=
DB
::
connection
(
'mysql'
)
->
table
(
'migrate_user'
)
->
where
(
'id'
,
1
)
->
update
([
'userid'
=>
$value
->
id
]);
// $updmigrate->userid = $value->id;
// $updmigrate->save();
}
//endforeach
}
//end if user
return
redirect
(
'users/list'
)
->
withSuccess
(
'Senarai staff telah dikemaskini'
);
}
...
...
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