Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
杨树贤
/
LC_api_news
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
129d59c5
authored
Dec 09, 2019
by
杨树贤
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
分页问题
parent
fd9b3a97
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
16 additions
and
12 deletions
app/Http/Controllers/CaseController.php
app/Model/ArticleModel.php
app/Services/CaseService.php
app/Http/Controllers/CaseController.php
View file @
129d59c5
...
...
@@ -15,7 +15,7 @@ class CaseController extends Controller
$pageSize
=
$request
->
get
(
'page_size'
);
$list
=
$service
->
getCaseList
(
$page
,
$pageSize
);
return
$this
->
Export
(
0
,
'ok'
,
[
'data'
=>
$list
]
);
return
$this
->
Export
(
0
,
'ok'
,
$list
);
}
public
function
show
(
Request
$request
,
CaseService
$service
)
...
...
app/Model/ArticleModel.php
View file @
129d59c5
...
...
@@ -47,7 +47,7 @@ class ArticleModel extends BaseModel
'banner_img'
,
'publish_time'
,
];
$
data
=
$this
->
select
(
$field
)
$
query
=
$this
->
select
(
$field
)
->
with
([
'article_tag'
=>
function
(
$query
)
{
$query
->
select
([
'id'
,
'art_id'
,
'tag'
,
'url'
]);
...
...
@@ -59,11 +59,13 @@ class ArticleModel extends BaseModel
$query
->
select
([
'type_id'
,
'type_name'
]);
},
])
->
where
(
$map
)
->
page
(
$page
,
$pageSize
)
->
where
(
$map
);
$data
=
$query
->
page
(
$page
,
$pageSize
)
->
orderBy
(
'art_id'
,
'desc'
)
->
get
()
->
toArray
();
$total
=
$query
->
count
();
return
$data
;
return
compact
(
'data'
,
'total'
)
;
}
public
function
getCase
(
$id
)
...
...
app/Services/CaseService.php
View file @
129d59c5
...
...
@@ -22,14 +22,16 @@ class CaseService extends BaseService
private
function
transform
(
$data
)
{
foreach
(
$data
as
$key
=>
&
$item
)
{
$item
[
'type'
]
=
array_get
(
$item
[
'type'
],
'type_name'
,
''
);
$item
[
'top_type'
]
=
array_get
(
$item
[
'top_type'
],
'type_name'
,
''
);
$item
[
'publish_time'
]
=
$item
[
'publish_time'
]
?
date
(
'Y-m-d H:i:s'
,
$item
[
'publish_time'
])
:
0
;
$item
[
'brand'
]
=
$item
[
'writer'
];
unset
(
$item
[
'writer'
]);
$item
[
'tags'
]
=
array_column
(
$item
[
'article_tag'
],
'tag'
);
unset
(
$item
[
'article_tag'
]);
if
(
!
empty
(
$data
[
'data'
]))
{
foreach
(
$data
[
'data'
]
as
$key
=>
&
$item
)
{
$item
[
'type'
]
=
array_get
(
$item
[
'type'
],
'type_name'
,
''
);
$item
[
'top_type'
]
=
array_get
(
$item
[
'top_type'
],
'type_name'
,
''
);
$item
[
'publish_time'
]
=
$item
[
'publish_time'
]
?
date
(
'Y-m-d H:i:s'
,
$item
[
'publish_time'
])
:
0
;
$item
[
'brand'
]
=
$item
[
'writer'
];
unset
(
$item
[
'writer'
]);
$item
[
'tags'
]
=
array_column
(
$item
[
'article_tag'
],
'tag'
);
unset
(
$item
[
'article_tag'
]);
}
}
unset
(
$item
);
...
...
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