Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Sarun Mungthanya
SpnPatch-Laravel
Commits
1097ea6b
Commit
1097ea6b
authored
Aug 29, 2024
by
Sarun Mungthanya
Browse files
add master file format
parent
f8d82fd3
Changes
35
Show whitespace changes
Inline
Side-by-side
.scannerwork/.sonar_lock
0 → 100644
View file @
1097ea6b
.scannerwork/report-task.txt
0 → 100644
View file @
1097ea6b
projectKey=SpnPatch
serverUrl=http://localhost:9000
serverVersion=10.6.0.92116
dashboardUrl=http://localhost:9000/dashboard?id=SpnPatch
ceTaskId=3cb72c3b-d0f7-4dc9-93aa-c683752993ab
ceTaskUrl=http://localhost:9000/api/ce/task?id=3cb72c3b-d0f7-4dc9-93aa-c683752993ab
app/Http/Controllers/AuthController.php
View file @
1097ea6b
...
...
@@ -53,9 +53,12 @@ class AuthController extends Controller
return
redirect
()
->
back
()
->
withErrors
(
$validator
)
->
withInput
();
}
$validated
=
$validator
->
validated
();
if
(
Auth
::
attempt
(
array
(
'email'
=>
$validated
[
'username'
],
'password'
=>
$validated
[
'password'
])))
{
if
(
Auth
::
attempt
(
array
(
'username'
=>
$validated
[
'username'
],
'password'
=>
$validated
[
'password'
])))
{
// $token = auth()->user()->createToken('app1_token')->plainTextToken;
// session(['shared_user_id' => auth()->id()]);
return
redirect
()
->
route
(
'index'
);
...
...
app/Http/Controllers/ExchangeRateController.php
View file @
1097ea6b
...
...
@@ -6,5 +6,9 @@ use Illuminate\Http\Request;
class
ExchangeRateController
extends
Controller
{
//
public
function
index
()
{
$menu
=
'ExchangeRate'
;
$currentContent
=
'ExchangeRate'
;
return
view
(
'home'
,
compact
(
'menu'
,
'currentContent'
));
}
}
app/Http/Controllers/FormatFileMasterContrller.php
0 → 100644
View file @
1097ea6b
<?php
namespace
App\Http\Controllers
;
use
Illuminate\Http\Request
;
class
FormatFileMasterContrller
extends
Controller
{
public
function
index
()
{
$menu
=
'FormatFileMaster'
;
$currentContent
=
'FormatFileMaster'
;
return
view
(
'home'
,
compact
(
'menu'
,
'currentContent'
));
}
}
app/Http/Controllers/MasterFileController.php
0 → 100644
View file @
1097ea6b
<?php
namespace
App\Http\Controllers
;
use
Illuminate\Http\Request
;
use
Illuminate\Support\Facades\DB
;
use
Illuminate\Support\Facades\Storage
;
use
Illuminate\Support\Facades\Http
;
use
Illuminate\Support\Facades\Log
;
class
MasterFileController
extends
Controller
{
public
function
index
()
{
$menu
=
'MasterFile'
;
$currentContent
=
'MasterFile'
;
return
view
(
'home'
,
compact
(
'menu'
,
'currentContent'
));
}
public
function
processFile
(
Request
$request
)
{
// Ensure the file is uploaded
if
(
!
$request
->
hasFile
(
'data'
)
||
!
$request
->
file
(
'data'
)
->
isValid
())
{
return
redirect
()
->
back
()
->
with
(
'error'
,
'Invalid file upload.'
);
}
// Get file details
$file
=
$request
->
file
(
'data'
);
$filePath
=
$file
->
getRealPath
();
$fileSize
=
$file
->
getSize
();
$filename
=
$file
->
getClientOriginalName
();
$timestampEEC
=
now
()
->
format
(
'Y-m-d'
);
$actDateTime
=
now
()
->
format
(
'Y-m-d H:i:s'
);
// Fetch format name
$format
=
$request
->
input
(
'format'
);
$config
=
DB
::
table
(
'conf_format_file'
)
->
where
(
'file'
,
$format
)
->
whereNotNull
(
'ac'
)
->
first
();
if
(
!
$config
)
{
return
redirect
()
->
back
()
->
with
(
'error'
,
'MasterFile Not config to EEC'
);
}
$typeEEC
=
$config
->
ac
;
// Send file to EEC if applicable
if
(
$request
->
input
(
'sendtoeec'
)
===
'on'
&&
!
empty
(
$typeEEC
))
{
$response
=
Http
::
attach
(
'file'
,
fopen
(
$filePath
,
'r'
),
$filename
)
->
post
(
env
(
'URL_MASTERFILE_EEC'
),
[
'type'
=>
$typeEEC
,
'timestamp'
=>
$timestampEEC
,
]);
$respStatus
=
$response
->
status
();
$respData
=
$response
->
body
();
DB
::
table
(
'ecc_transactions'
)
->
insert
([
'uid'
=>
$request
->
input
(
'UID'
),
'type_eec'
=>
$typeEEC
,
'filename'
=>
$filename
,
'request_data'
=>
json_encode
([
'type'
=>
$typeEEC
,
'file'
=>
$filename
,
'timestamp'
=>
$timestampEEC
,
]),
'act_datetime'
=>
$actDateTime
,
'response_status'
=>
$respStatus
,
'response_data'
=>
$respData
,
]);
if
(
$respStatus
===
200
)
{
return
redirect
()
->
back
()
->
with
(
'success'
,
'Send MasterFile To EEC'
);
}
else
{
return
redirect
()
->
back
()
->
with
(
'error'
,
'Cannot Send MasterFile To EEC'
);
}
}
// Process file and create patches
if
(
$request
->
input
(
'createpatch'
)
===
'on'
)
{
$data
=
$this
->
readTxt
(
$filePath
,
$format
,
$request
->
input
(
'ac'
),
$request
->
input
(
'sizerow'
),
$request
->
input
(
'notsplit'
));
foreach
(
$data
as
$key
=>
$sqlPack
)
{
$patchCode
=
$this
->
generatePatchCode
(
$sqlPack
);
DB
::
table
(
'conf_smartupdate'
)
->
insert
([
'patchname'
=>
"Update Master File
{
$config
->
name
}
วันที่ "
.
now
()
->
format
(
'j'
)
.
' เดือน '
.
now
()
->
format
(
'n'
)
.
' ปี '
.
now
()
->
format
(
'Y'
)
.
' Part '
.
(
$key
+
1
),
'pdate'
=>
now
(),
'plevel'
=>
'Critical'
,
'pcode'
=>
'SHIPPINGNET'
,
'major_version'
=>
'ALL'
,
'pdesc'
=>
$config
->
name
,
'powner'
=>
$request
->
input
(
'UID'
),
'ptype'
=>
'UPDATE MASTER'
,
'papprovedate'
=>
now
(),
'patchcode'
=>
$patchCode
,
'uninstall'
=>
'DONE=1;'
,
'patchcode_server'
=>
'DONE=1;'
,
]);
}
return
redirect
()
->
back
()
->
with
(
'success'
,
'Successful Created Patch.'
);
}
return
redirect
()
->
back
()
->
with
(
'error'
,
'File processing failed.'
);
}
private
function
readTxt
(
$filePath
,
$format
,
$ac
,
$sizeRow
,
$notSplit
)
{
// Implement file reading and SQL generation logic
// This method should return an array of SQL packs
}
private
function
generatePatchCode
(
$sqlPack
)
{
// Implement patch code generation logic
// This method should return a string of patch code
}
}
app/Http/Controllers/SelectListController.php
0 → 100644
View file @
1097ea6b
<?php
namespace
App\Http\Controllers
;
use
App\Models\Group
;
use
App\Models\Role
;
use
App\Models\User
;
use
Illuminate\Http\Request
;
class
SelectListController
extends
Controller
{
public
function
getRoles
()
{
$roles
=
Role
::
select
(
'id'
,
'name'
)
->
get
();
$formattedRoles
=
[];
foreach
(
$roles
as
$role
)
{
$formattedRoles
[]
=
[
'id'
=>
$role
->
id
,
'name'
=>
$role
->
name
,
];
}
return
response
()
->
json
([
'roles'
=>
$formattedRoles
]);
}
public
function
getUsers
()
{
$users
=
User
::
select
(
'id'
,
'username'
,
'email'
)
->
get
();
$formattedUsers
=
[];
foreach
(
$users
as
$user
)
{
$formattedUsers
[]
=
[
'id'
=>
$user
->
id
,
'name'
=>
$user
->
username
,
'email'
=>
$user
->
email
,
];
}
return
response
()
->
json
([
'users'
=>
$formattedUsers
]);
}
public
function
getGroups
()
{
$users
=
Group
::
select
(
'id'
,
'name'
)
->
get
();
$formattedGroups
=
[];
foreach
(
$users
as
$user
)
{
$formattedGroups
[]
=
[
'id'
=>
$user
->
id
,
'name'
=>
$user
->
name
,
];
}
return
response
()
->
json
([
'groups'
=>
$formattedGroups
]);
}
}
app/Http/Controllers/TransferDataController.php
0 → 100644
View file @
1097ea6b
<?php
namespace
App\Http\Controllers
;
use
Illuminate\Http\Request
;
use
Illuminate\Support\Facades\DB
;
use
Illuminate\Support\Facades\Hash
;
class
TransferDataController
extends
Controller
{
public
function
transferUserData
()
{
set_time_limit
(
0
);
$batchSize
=
100
;
// Number of records to process at a time
$offset
=
0
;
while
(
true
)
{
$oldUsers
=
DB
::
table
(
'tab_user'
)
->
select
([
'UID'
,
DB
::
raw
(
'CONVERT(UCODE USING utf8) AS UCODE'
),
DB
::
raw
(
'CONVERT(USERNAME USING utf8) AS USERNAME'
),
DB
::
raw
(
'CONVERT(PASSWORD USING utf8) AS PASSWORD'
),
DB
::
raw
(
'CONVERT(FIRSTNAME USING utf8) AS FIRSTNAME'
),
DB
::
raw
(
'CONVERT(LASTNAME USING utf8) AS LASTNAME'
),
DB
::
raw
(
'CONVERT(EMAIL USING utf8) AS EMAIL'
),
DB
::
raw
(
'CONVERT(PHONE USING utf8) AS PHONE'
),
'APPROVED'
,
'APPROVEDATE'
,
'STATUSLOGIN'
,
'LASTLOGIN'
,
DB
::
raw
(
'CONVERT(ACTIVITY USING utf8) AS ACTIVITY'
),
'ACTIVITY_TIME'
,
DB
::
raw
(
'CONVERT(PAYMENT_USER USING utf8) AS PAYMENT_USER'
),
DB
::
raw
(
'CONVERT(PAYMENT_PASS USING utf8) AS PAYMENT_PASS'
),
DB
::
raw
(
'CONVERT(PAYMENT_ORG USING utf8) AS PAYMENT_ORG'
),
DB
::
raw
(
'CONVERT(BUCODE USING utf8) AS BUCODE'
),
])
->
offset
(
$offset
)
->
limit
(
$batchSize
)
->
get
();
if
(
$oldUsers
->
isEmpty
())
{
break
;
// No more records to process
}
foreach
(
$oldUsers
as
$oldUser
)
{
// if (is_null($oldUser->EMAIL)) {
// // Skip this record if email is NULL
// continue;
// }
try
{
DB
::
table
(
'users'
)
->
insert
([
'uid'
=>
$oldUser
->
UID
,
'user_code'
=>
$oldUser
->
UCODE
,
'username'
=>
$oldUser
->
USERNAME
,
'password'
=>
Hash
::
make
(
$oldUser
->
PASSWORD
),
'first_name'
=>
$oldUser
->
FIRSTNAME
,
'last_name'
=>
$oldUser
->
LASTNAME
,
'email'
=>
$oldUser
->
EMAIL
??
''
,
'phone'
=>
$oldUser
->
PHONE
,
'is_approved'
=>
$oldUser
->
APPROVED
===
'Y'
?
true
:
false
,
'approved_at'
=>
isset
(
$oldUser
->
APPROVEDDATE
)
?
$oldUser
->
APPROVEDDATE
:
null
,
'status_login'
=>
$oldUser
->
STATUSLOGIN
,
'last_login_at'
=>
isset
(
$oldUser
->
LASTLOGIN
)
?
$oldUser
->
LASTLOGIN
:
null
,
'activity'
=>
isset
(
$oldUser
->
ACTIVITY
)
?
$oldUser
->
ACTIVITY
:
null
,
'activity_time'
=>
isset
(
$oldUser
->
ACTIVITY_TIME
)
?
$oldUser
->
ACTIVITY_TIME
:
null
,
'payment_username'
=>
isset
(
$oldUser
->
PAYMENT_USER
)
?
$oldUser
->
PAYMENT_USER
:
null
,
'payment_password'
=>
isset
(
$oldUser
->
PAYMENT_PASS
)
?
Hash
::
make
(
$oldUser
->
PAYMENT_PASS
)
:
null
,
'payment_organization'
=>
isset
(
$oldUser
->
PAYMENT_ORG
)
?
$oldUser
->
PAYMENT_ORG
:
null
,
'bu_code'
=>
isset
(
$oldUser
->
BUCODE
)
?
$oldUser
->
BUCODE
:
null
,
'created_at'
=>
now
(),
'updated_at'
=>
now
(),
'deleted_at'
=>
null
,
]);
}
catch
(
\
Illuminate\Database\QueryException
$ex
)
{
if
(
$ex
->
getCode
()
==
23000
)
{
continue
;
// Skip to the next iteration if duplicate entry
}
else
{
throw
$ex
;
}
}
}
$offset
+=
$batchSize
;
// Move to the next batch
}
return
"Data transferred successfully!"
;
}
}
app/Http/Livewire/Pages/FormatFileMaster/FileCreate.php
0 → 100644
View file @
1097ea6b
<?php
namespace
App\Http\Livewire\Pages\FormatFileMaster
;
use
Livewire\Component
;
use
App\Models\ConfFormatFile
;
use
Livewire\WithFileUploads
;
class
FileCreate
extends
Component
{
use
WithFileUploads
;
public
$name
;
public
$file
;
protected
$rules
=
[
'name'
=>
'required|string|max:255'
,
];
public
function
updatedFile
()
{
$this
->
validate
([
'file'
=>
'required|file|mimes:txt|max:10240'
,
// 10MB max file size
]);
}
public
function
save
()
{
$this
->
validate
();
if
(
$this
->
file
)
{
$filePath
=
$this
->
file
->
store
(
'runtime/format'
,
'public'
);
}
$date
=
date
(
"Ymd"
);
$timestamp
=
date
(
"His"
);
$fileFormat
=
new
ConfFormatFile
;
$fileFormat
->
name
=
$this
->
name
;
$fileFormat
->
file
=
$filePath
;
$fileFormat
->
date
=
$date
;
$fileFormat
->
timestamp
=
$timestamp
;
$fileFormat
->
save
();
$this
->
reset
([
'name'
,
'file'
]);
return
redirect
()
->
route
(
'format-file-master.index'
)
->
with
(
'message'
,
'Format File saved successfully.'
);
}
public
function
render
()
{
return
view
(
'livewire.pages.format-file-master.file-create'
);
}
}
app/Http/Livewire/Pages/FormatFileMaster/FileEdit.php
0 → 100644
View file @
1097ea6b
<?php
namespace
App\Http\Livewire\Pages\FormatFileMaster
;
use
Livewire\Component
;
use
App\Models\Role
;
use
App\Models\Permission
;
use
Illuminate\Http\Request
;
class
FormatFileEdit
extends
Component
{
public
$editRoleId
;
public
$permissions
;
public
$roleId
;
public
$role
;
public
$name
,
$description
,
$permission_lists
=
[];
protected
$rules
=
[
'role.name'
=>
'required'
,
];
public
function
mount
(
$editRoleId
,
$permissions
)
{
$this
->
editRoleId
=
$editRoleId
;
$this
->
permissions
=
$permissions
;
$this
->
role
=
Role
::
findOrFail
(
$editRoleId
);
$this
->
name
=
$this
->
role
->
name
;
$this
->
description
=
$this
->
role
->
description
;
$this
->
permission_lists
=
$this
->
role
->
permissions
->
pluck
(
'id'
)
->
toArray
();
$this
->
permissions
=
Permission
::
all
();
}
public
function
render
()
{
$permission_lists
=
$this
->
permission_lists
;
return
view
(
'livewire.pages.role.role-edit'
,
compact
(
'permission_lists'
));
}
public
function
submitEditForm
(
$selectedList
)
{
// $this->validate();
$this
->
permission_lists
=
array_map
(
'intval'
,
$selectedList
);
$this
->
role
->
name
=
$this
->
name
;
$this
->
role
->
description
=
$this
->
description
;
$this
->
role
->
permissions
()
->
sync
(
$this
->
permission_lists
);
$this
->
role
->
save
();
$this
->
emit
(
'showRoleList'
,
'Role successfully updated.'
);
}
public
function
goBack
()
{
$this
->
emit
(
'showRoleList'
,
''
);
}
}
app/Http/Livewire/Pages/FormatFileMaster/FileIndex.php
0 → 100644
View file @
1097ea6b
<?php
namespace
App\Http\Livewire\Pages\FormatFileMaster
;
use
App\Models\ConfFormatFile
;
use
Livewire\Component
;
use
Illuminate\Support\Facades\Hash
;
use
Illuminate\Support\Facades\Validator
;
use
App\Models\Role
;
use
App\Models\Permission
;
use
Livewire\WithPagination
;
class
FileIndex
extends
Component
{
use
WithPagination
;
public
$perPage
=
10
;
public
$searchSelected
=
'name'
;
public
$editId
;
public
$deleteId
;
public
$keyword
=
''
;
public
$route
=
''
;
public
$selectedOption
=
'name'
;
public
$searchBy
;
public
$menu
;
public
$action
=
'list'
;
public
$message
;
public
$showDeleteListModal
=
false
;
public
$showMessage
=
false
;
protected
$listeners
=
[
'showRoleList'
,
'deleteItem'
,
'deleteSelected'
];
public
function
mount
()
{
$this
->
searchBy
=
[
'name'
=>
'Name'
,
'fiel'
=>
'File'
];
$this
->
message
=
session
(
'message'
);
}
public
function
render
()
{
;
$query
=
ConfFormatFile
::
select
(
'formatservice_ID'
,
'name'
,
'file'
,
'date'
,
'timestamp'
,
'ac'
);
if
(
$this
->
searchSelected
&&
$this
->
keyword
)
{
$query
->
where
(
$this
->
searchSelected
,
'LIKE'
,
'%'
.
$this
->
keyword
.
'%'
);
}
$query
->
orderBy
(
'formatservice_ID'
,
'DESC'
);
$results
=
$query
->
paginate
(
$this
->
perPage
);
return
view
(
'livewire.pages.format-file-master.file-index'
,
compact
(
'results'
));
}
public
function
search
()
{
$this
->
resetPage
();
}
public
function
showListForm
()
{
$this
->
action
=
'list'
;
}
public
function
showAddForm
()
{
$this
->
action
=
'add'
;
}
public
function
showEditForm
(
$id
)
{
$this
->
editId
=
$id
;
$this
->
action
=
'edit'
;
}
public
function
showDeleteModal
(
$patchFileId
)
{
$this
->
emit
(
'showDeleteModal'
,
$patchFileId
);
}
public
function
deleteItem
(
$id
)
{
$file
=
ConfFormatFile
::
where
(
"formatservice_ID"
,
$id
)
->
delete
();
$message
=
"Deleted Patch ID : "
.
json_encode
(
$file
)
.
" Successfully"
;
$this
->
message
=
$message
;
}
}
app/Http/Livewire/Pages/ServerLicense/ServerLicenseEdit.php
View file @
1097ea6b
...
...
@@ -690,11 +690,18 @@ class ServerLicenseEdit extends Component
'cs.PID'
,
'cs.PATCHNAME'
,
'cs.PAPPROVEDATE'
,
'cs.PDESC'
'cs.PDESC'
,
DB
::
raw
(
"CASE WHEN cp.TaskStatus = 999 THEN 'Success'
WHEN cp.TaskStatus = 0 THEN 'Waiting Receive'
WHEN cp.TaskStatus = 1 THEN 'See Patch'
WHEN cp.TaskStatus = 2 THEN 'Error Recieved'
ELSE cp.TaskStatus END as TaskStatusLabel"
)
)
->
where
(
'cp.ServerID'
,
$this
->
licenseId
)
->
orderBy
(
$this
->
sortHistoryField
,
$this
->
sortHistoryDirection
)
->
paginate
(
$this
->
perPage
);
}
public
function
sortHistoryBy
(
$field
)
{
...
...
app/Http/Livewire/Pages/User/UserEdit.php
View file @
1097ea6b
...
...
@@ -11,7 +11,7 @@ class UserEdit extends Component
public
$editUserId
;
public
$userId
;
public
$user
;
public
$name
,
$email
,
$current_password
,
$new_password
,
$new_password_confirmation
,
$changePassword
=
false
;
public
$
user
name
,
$email
,
$current_password
,
$new_password
,
$new_password_confirmation
,
$changePassword
=
false
;
public
$group_lists
;
protected
function
rules
()
...
...
@@ -44,7 +44,7 @@ class UserEdit extends Component
{
$this
->
editUserId
=
$editUserId
;
$this
->
user
=
User
::
findOrFail
(
$editUserId
);
$this
->
name
=
$this
->
user
->
name
;
$this
->
user
name
=
$this
->
user
->
user
name
;
$this
->
email
=
$this
->
user
->
email
;
$this
->
group_lists
=
$this
->
user
->
groups
()
->
pluck
(
'group_id'
)
->
implode
(
','
);
}
...
...
@@ -67,7 +67,7 @@ class UserEdit extends Component
$this
->
addError
(
'current_password'
,
'The current password is incorrect.'
);
return
;
}
$this
->
user
->
name
=
$this
->
name
;
$this
->
user
->
user
name
=
$this
->
user
name
;
$this
->
user
->
email
=
$this
->
email
;
if
(
$this
->
changePassword
)
{
...
...
app/Http/Livewire/Pages/User/UserIndex.php
View file @
1097ea6b
...
...
@@ -3,6 +3,7 @@
namespace
App\Http\Livewire\Pages\User
;
use
Livewire\Component
;
use
Illuminate\Support\Facades\Auth
;
use
Illuminate\Support\Facades\Hash
;
use
Illuminate\Support\Facades\Validator
;
use
App\Models\User
;
...
...
@@ -33,7 +34,7 @@ class UserIndex extends Component
public
function
mount
()
{
$this
->
searchBy
=
[
'name'
=>
'
N
ame'
,
'
user
name'
=>
'
Usern
ame'
,
];
// $this->message = session('message');
// $this->showMessage = true;
...
...
@@ -60,7 +61,7 @@ class UserIndex extends Component
public
function
showUserCreateForm
()
{
if
(
!
\
Auth
::
user
()
->
hasPermissions
([
'add-user'
]))
{
if
(
!
Auth
::
user
()
->
hasPermissions
([
'add-user'
]))
{
$this
->
showNoPermissionModal
=
TRUE
;
return
;
}
...
...
@@ -70,7 +71,7 @@ class UserIndex extends Component
public
function
showUserEditForm
(
$UserId
)
{
if
(
!
\
Auth
::
user
()
->
hasPermissions
([
'edit-user'
]))
{
if
(
!
Auth
::
user
()
->
hasPermissions
([
'edit-user'
]))
{
$this
->
showNoPermissionModal
=
TRUE
;
return
;
}
...
...
@@ -98,7 +99,7 @@ class UserIndex extends Component
}
public
function
deleteItem
(
$deleteUserId
)
{
if
(
!
\
Auth
::
user
()
->
hasPermissions
([
'delete-user'
]))
{
if
(
!
Auth
::
user
()
->
hasPermissions
([
'delete-user'
]))
{
$this
->
showNoPermissionModal
=
TRUE
;
return
;
}
...
...
@@ -115,7 +116,7 @@ class UserIndex extends Component
}
public
function
deleteSelected
(
$selectedUsers
)
{
if
(
!
\
Auth
::
user
()
->
hasPermissions
([
'delete-user'
]))
{
if
(
!
Auth
::
user
()
->
hasPermissions
([
'delete-user'
]))
{
$this
->
showNoPermissionModal
=
TRUE
;
return
;
}
...
...
app/Models/ConfFormatFile.php
View file @
1097ea6b
...
...
@@ -7,6 +7,7 @@ use Illuminate\Database\Eloquent\Model;
class
ConfFormatFile
extends
Model
{
protected
$table
=
'conf_format_file'
;
public
$timestamps
=
false
;
protected
$fillable
=
[
'formatservice_ID'
,
'name'
,
...
...
app/Models/User.php
View file @
1097ea6b
...
...
@@ -21,7 +21,7 @@ class User extends Authenticatable
*/
protected
$dates
=
[
'deleted_at'
];
protected
$fillable
=
[
'name'
,
'
user
name'
,
'uid'
,
'email'
,
'password'
,
...
...
database/migrations/2014_10_12_00000
0
_create_users_table.php
→
database/migrations/2014_10_12_00000
1
_create_users_table.php
View file @
1097ea6b
...
...
@@ -14,14 +14,31 @@ return new class extends Migration
public
function
up
()
{
Schema
::
create
(
'users'
,
function
(
Blueprint
$table
)
{
$table
->
id
();
$table
->
string
(
'uid'
);
$table
->
string
(
'name'
);
$table
->
string
(
'user_code'
,
50
)
->
unique
()
->
nullable
();
$table
->
string
(
'username'
,
50
)
->
nullable
();
$table
->
string
(
'password'
);
$table
->
string
(
'first_name'
,
100
)
->
nullable
();
$table
->
string
(
'last_name'
,
100
)
->
nullable
();
$table
->
string
(
'email'
)
->
unique
();
$table
->
timestamp
(
'email_verified_at'
)
->
nullable
();
$table
->
string
(
'password'
);
$table
->
rememberToken
();
$table
->
string
(
'phone'
,
20
)
->
nullable
();
$table
->
boolean
(
'is_approved'
)
->
default
(
false
);
$table
->
timestamp
(
'approved_at'
)
->
nullable
();
$table
->
string
(
'status_login'
,
50
)
->
nullable
();
$table
->
timestamp
(
'last_login_at'
)
->
nullable
();
$table
->
string
(
'activity'
)
->
nullable
();
$table
->
timestamp
(
'activity_time'
)
->
nullable
();
$table
->
string
(
'payment_username'
,
50
)
->
nullable
();
$table
->
string
(
'payment_password'
)
->
nullable
();
$table
->
string
(
'payment_organization'
,
100
)
->
nullable
();
$table
->
string
(
'bu_code'
,
50
)
->
nullable
();
$table
->
timestamps
();
$table
->
softDeletes
();
});
}
...
...
database/seeders/DatabaseSeeder.php
View file @
1097ea6b
...
...
@@ -8,6 +8,7 @@ use App\Models\User;
use
App\Models\Group
;
use
App\Models\Company
;
use
App\Models\CompanyType
;
use
Illuminate\Support\Str
;
class
DatabaseSeeder
extends
Seeder
{
...
...
@@ -21,28 +22,34 @@ class DatabaseSeeder extends Seeder
DB
::
table
(
'company_types'
)
->
insert
([
[
'name'
=>
'Netbay Admin'
],
[
'name'
=>
'Broker'
],
[
'name'
=>
'Importer'
]
]);
//
DB::table('company_types')->insert([
//
['name' => 'Netbay Admin'],
//
['name' => 'Broker'],
//
['name' => 'Importer']
//
]);
$this
->
call
([
PermissionSeeder
::
class
,
RoleSeeder
::
class
,
CompaniesSeeder
::
class
,
GroupSeeder
::
class
,
]);
//
$this->call([
//
PermissionSeeder::class,
//
RoleSeeder::class,
//
CompaniesSeeder::class,
//
GroupSeeder::class,
//
]);
\
App\Models\User
::
factory
()
->
create
([
'name'
=>
'Test User'
,
'email'
=>
'test@example.com'
,
'password'
=>
bcrypt
(
'password'
),
]);
// \App\Models\User::factory()->create([
// 'username' => 'Test User',
// 'email' => 'test@example.com',
// 'password' => bcrypt('password'),
// 'uid' => Str::random(21)
// ]);
$users
=
[
[
'name'
=>
'Sarun'
,
'email'
=>
'sarun@netbay.co.th'
,
'password'
=>
bcrypt
(
'password'
)],
[
'username'
=>
'Sarun'
,
'email'
=>
'sarun@netbay.co.th'
,
'password'
=>
bcrypt
(
'password'
),
'uid'
=>
Str
::
random
(
21
)
],
];
foreach
(
$users
as
$userData
)
{
...
...
resources/js/pages/groupSelect.js
0 → 100644
View file @
1097ea6b
const
groupSelect
=
{
group
:
{
valueField
:
"
id
"
,
searchField
:
"
name
"
,
options
:
[],
// Initialize empty array for options
placeholder
:
""
,
placeholder
:
"
Select the group
"
,
plugins
:
[
'
remove_button
'
],
closeAfterSelect
:
true
,
onDelete
:
function
(
values
)
{
},
render
:
{
option
:
function
(
data
,
escape
)
{
if
(
!
data
.
name
)
{
console
.
error
(
"
Invalid data for option:
"
,
data
);
return
""
;
}
return
`<div class="flex space-x-3">
<div class="flex flex-col">
<span>
${
escape
(
data
.
name
)}
</span>
</div>
</div>`
;
},
item
:
function
(
data
,
escape
)
{
if
(
!
data
.
name
)
{
console
.
error
(
"
Invalid data for item:
"
,
data
);
return
""
;
}
return
`<span class="badge rounded-full bg-primary dark:bg-accent text-white px-2 py-2 mb-2 mr-2">
<span class="mx-2">
${
escape
(
data
.
name
)}
</span>
</span>`
;
},
},
},
};
const
fetchGroups
=
(
groupSelect
)
=>
{
return
fetch
(
'
/get-groups
'
)
.
then
(
response
=>
response
.
json
())
.
then
(
data
=>
{
if
(
!
data
.
groups
||
!
Array
.
isArray
(
data
.
groups
))
{
console
.
error
(
"
Invalid response format:
"
,
data
);
return
;
}
groupSelect
.
group
.
options
=
data
.
groups
;
})
.
catch
(
error
=>
console
.
error
(
'
Error fetching group data:
'
,
error
));
};
export
{
groupSelect
,
fetchGroups
};
\ No newline at end of file
resources/js/pages/index.js
View file @
1097ea6b
export
{
charts
}
from
"
./apexchartDemo
"
;
export
{
tomSelect
}
from
"
./tomselectDemo
"
;
export
{
userSelect
,
fetchUsers
}
from
"
./userSelect
"
;
export
{
roleSelect
,
fetchRoles
}
from
"
./roleSelect
"
;
export
{
groupSelect
,
fetchGroups
}
from
"
./groupSelect
"
;
export
{
serverLicenseSelect
,
fetchServerLicenses
}
from
"
./serverLicenseSelect
"
;
export
*
as
tables
from
"
./tablesDemo
"
;
export
*
as
formValidation
from
"
./formValidationDemo
"
;
...
...
Prev
1
2
Next
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