Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
赵增煜
/
tzt-admin
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
8d6676da
authored
Nov 21, 2024
by
lujunyi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
药店信息修改判断
parent
7c041abb
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
14 deletions
+17
-14
app/Admin/Controllers/PharmacyController.php
+17
-14
No files found.
app/Admin/Controllers/PharmacyController.php
View file @
8d6676da
...
...
@@ -171,21 +171,24 @@ protected function form()
$admin
=
Administrator
::
where
(
'pharmacy_id'
,
$pharmacyId
)
->
first
();
if
(
$admin
)
{
// 如果存在,更新相应字段
$admin
->
username
=
$mobile
;
// 更新账号
$admin
->
name
=
$name
;
// 更新账号姓名
$admin
->
save
();
if
(
$mobile
&&
$name
)
{
$admin
->
username
=
$mobile
;
// 更新账号
$admin
->
name
=
$name
;
// 更新账号姓名
$admin
->
save
();
}
}
else
{
// 如果不存在,新增管理员
$admin
=
new
Administrator
();
$admin
->
username
=
$mobile
;
// 药店手机号作为管理员账号
$admin
->
name
=
$name
;
// 药店名称当做用户的姓名
$admin
->
password
=
bcrypt
(
Str
::
random
(
10
));
// 设置管理员密码
$admin
->
pharmacy_id
=
$pharmacyId
;
// 药店ID
$admin
->
save
();
// 保存新管理员
// 关联药店管理员角色
$admin
->
roles
()
->
attach
(
$role
->
id
);
if
(
$mobile
&&
$name
&&
$pharmacyId
)
{
$admin
=
new
Administrator
();
$admin
->
username
=
$mobile
;
// 药店手机号作为管理员账号
$admin
->
name
=
$name
;
// 药店名称当做用户的姓名
$admin
->
password
=
bcrypt
(
Str
::
random
(
10
));
// 设置管理员密码
$admin
->
pharmacy_id
=
$pharmacyId
;
// 药店ID
$admin
->
save
();
// 保存新管理员
// 关联药店管理员角色
$admin
->
roles
()
->
attach
(
$role
->
id
);
}
}
DB
::
commit
();
}
catch
(
\Exception
$e
)
{
...
...
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