Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
semour
/
semour_web
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
b9a9aaa0
authored
Nov 10, 2022
by
杨树贤
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
优化地址存储国家的字段
parent
8908a842
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
18 additions
and
4 deletions
.idea/workspace.xml
app/Http/Services/UserAddressService.php
app/Models/UserAddressModel.php
.idea/workspace.xml
View file @
b9a9aaa0
...
@@ -3,9 +3,8 @@
...
@@ -3,9 +3,8 @@
<component
name=
"ChangeListManager"
>
<component
name=
"ChangeListManager"
>
<list
default=
"true"
id=
"fb90add0-1393-48c2-9f26-72365d42cd03"
name=
"变更"
comment=
""
>
<list
default=
"true"
id=
"fb90add0-1393-48c2-9f26-72365d42cd03"
name=
"变更"
comment=
""
>
<change
beforePath=
"$PROJECT_DIR$/.idea/workspace.xml"
beforeDir=
"false"
afterPath=
"$PROJECT_DIR$/.idea/workspace.xml"
afterDir=
"false"
/>
<change
beforePath=
"$PROJECT_DIR$/.idea/workspace.xml"
beforeDir=
"false"
afterPath=
"$PROJECT_DIR$/.idea/workspace.xml"
afterDir=
"false"
/>
<change
beforePath=
"$PROJECT_DIR$/app/Http/Controllers/Api/UserAddressApiController.php"
beforeDir=
"false"
afterPath=
"$PROJECT_DIR$/app/Http/Controllers/Api/UserAddressApiController.php"
afterDir=
"false"
/>
<change
beforePath=
"$PROJECT_DIR$/app/Http/Requests/UserAddressSave.php"
beforeDir=
"false"
afterPath=
"$PROJECT_DIR$/app/Http/Requests/UserAddressSave.php"
afterDir=
"false"
/>
<change
beforePath=
"$PROJECT_DIR$/app/Http/Services/UserAddressService.php"
beforeDir=
"false"
afterPath=
"$PROJECT_DIR$/app/Http/Services/UserAddressService.php"
afterDir=
"false"
/>
<change
beforePath=
"$PROJECT_DIR$/app/Http/Services/UserAddressService.php"
beforeDir=
"false"
afterPath=
"$PROJECT_DIR$/app/Http/Services/UserAddressService.php"
afterDir=
"false"
/>
<change
beforePath=
"$PROJECT_DIR$/app/Models/UserAddressModel.php"
beforeDir=
"false"
afterPath=
"$PROJECT_DIR$/app/Models/UserAddressModel.php"
afterDir=
"false"
/>
<change
beforePath=
"$PROJECT_DIR$/bootstrap/app.php"
beforeDir=
"false"
afterPath=
"$PROJECT_DIR$/bootstrap/app.php"
afterDir=
"false"
/>
<change
beforePath=
"$PROJECT_DIR$/bootstrap/app.php"
beforeDir=
"false"
afterPath=
"$PROJECT_DIR$/bootstrap/app.php"
afterDir=
"false"
/>
<change
beforePath=
"$PROJECT_DIR$/bootstrap/cache/.gitignore"
beforeDir=
"false"
afterPath=
"$PROJECT_DIR$/bootstrap/cache/.gitignore"
afterDir=
"false"
/>
<change
beforePath=
"$PROJECT_DIR$/bootstrap/cache/.gitignore"
beforeDir=
"false"
afterPath=
"$PROJECT_DIR$/bootstrap/cache/.gitignore"
afterDir=
"false"
/>
<change
beforePath=
"$PROJECT_DIR$/storage/app/.gitignore"
beforeDir=
"false"
afterPath=
"$PROJECT_DIR$/storage/app/.gitignore"
afterDir=
"false"
/>
<change
beforePath=
"$PROJECT_DIR$/storage/app/.gitignore"
beforeDir=
"false"
afterPath=
"$PROJECT_DIR$/storage/app/.gitignore"
afterDir=
"false"
/>
...
@@ -189,7 +188,7 @@
...
@@ -189,7 +188,7 @@
<workItem
from=
"1666835076791"
duration=
"693000"
/>
<workItem
from=
"1666835076791"
duration=
"693000"
/>
<workItem
from=
"1667266026118"
duration=
"40321000"
/>
<workItem
from=
"1667266026118"
duration=
"40321000"
/>
<workItem
from=
"1667959054458"
duration=
"183000"
/>
<workItem
from=
"1667959054458"
duration=
"183000"
/>
<workItem
from=
"1667986756173"
duration=
"5
340
000"
/>
<workItem
from=
"1667986756173"
duration=
"5
874
000"
/>
</task>
</task>
<servers
/>
<servers
/>
</component>
</component>
...
...
app/Http/Services/UserAddressService.php
View file @
b9a9aaa0
...
@@ -2,6 +2,7 @@
...
@@ -2,6 +2,7 @@
namespace
App\Http\Services
;
namespace
App\Http\Services
;
use
App\Models\CountryModel
;
use
App\Models\UserAddressModel
;
use
App\Models\UserAddressModel
;
use
Illuminate\Support\Facades\DB
;
use
Illuminate\Support\Facades\DB
;
...
@@ -37,15 +38,24 @@ class UserAddressService
...
@@ -37,15 +38,24 @@ class UserAddressService
{
{
$address
=
UserAddressModel
::
select
([
'*'
])
->
where
(
'address_id'
,
$addressId
)
$address
=
UserAddressModel
::
select
([
'*'
])
->
where
(
'address_id'
,
$addressId
)
->
first
()
->
toArray
();
->
first
()
->
toArray
();
$address
[
'country'
]
=
CountryModel
::
where
(
'id'
,
$address
[
'country'
])
->
value
(
'name'
);
return
$address
;
return
$address
;
}
}
public
static
function
getUserAddressList
(
$userId
)
public
static
function
getUserAddressList
(
$userId
)
{
{
$query
=
UserAddressModel
::
where
(
'user_id'
,
$userId
)
->
orderBy
(
'address_id'
,
'desc'
);
$query
=
UserAddressModel
::
with
([
'country'
=>
function
(
$q
)
{
$q
->
select
([
'id'
,
'name'
,
]);
}
])
->
where
(
'user_id'
,
$userId
)
->
orderBy
(
'address_id'
,
'desc'
);
$result
=
$query
->
paginate
(
10
)
->
toArray
();
$result
=
$query
->
paginate
(
10
)
->
toArray
();
foreach
(
$result
[
'data'
]
as
&
$item
)
{
foreach
(
$result
[
'data'
]
as
&
$item
)
{
$item
[
'create_time'
]
=
date
(
'Y-m-d H:i:s'
,
$item
[
'create_time'
]);
$item
[
'create_time'
]
=
date
(
'Y-m-d H:i:s'
,
$item
[
'create_time'
]);
$item
[
'country'
]
=
\Arr
::
get
(
$item
[
'country'
],
'name'
);
}
}
unset
(
$item
);
unset
(
$item
);
return
$result
;
return
$result
;
...
...
app/Models/UserAddressModel.php
View file @
b9a9aaa0
...
@@ -19,4 +19,9 @@ class UserAddressModel extends Model
...
@@ -19,4 +19,9 @@ class UserAddressModel extends Model
return
$this
->
belongsTo
(
UserModel
::
class
);
return
$this
->
belongsTo
(
UserModel
::
class
);
}
}
public
function
country
()
{
return
$this
->
hasOne
(
CountryModel
::
class
,
'id'
,
'country'
);
}
}
}
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