Toggle navigation
Toggle navigation
This project
Loading...
Sign in
OnePoem
/
OnePoem-Server
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
李帅
2022-07-19 22:10:32 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
ae5cf56ccbc5e27aded8b2976bd06574a3b3d2d9
ae5cf56c
1 parent
d7cf7efb
1.收藏列表改用get
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
1 deletions
app/Http/Controllers/V1/ImmerseController.php
app/Models/Collect.php
app/Http/Controllers/V1/ImmerseController.php
View file @
ae5cf56
...
...
@@ -158,10 +158,20 @@ class ImmerseController extends Controller
$user
=
$request
->
user
();
$
data
=
Collect
::
query
()
->
where
([
'user_id'
=>
$user
->
id
,
'state'
=>
1
])
$
collects
=
Collect
::
query
()
->
where
([
'user_id'
=>
$user
->
id
,
'state'
=>
1
])
->
orderByDesc
(
'created_at'
)
->
skip
((
$page
-
1
)
*
$page_size
)
->
take
(
$page_size
+
1
)
->
get
();
$data
=
[];
foreach
(
$collects
as
$collect
){
$data
[
'content'
]
=
$collect
->
immerse
->
content
;
$data
[
'thumbnail'
]
=
$collect
->
immerse
->
thumbnail
;
$data
[
'url'
]
=
$collect
->
immerse
->
url
;
$data
[
'type'
]
=
$collect
->
immerse
->
type
;
$data
[
'is_praise'
]
=
$collect
->
immerse
->
isPraise
(
$collect
->
id
,
$user
->
id
);
$data
[
'is_collect'
]
=
$collect
->
immerse
->
isCollect
(
$collect
->
id
,
$user
->
id
);
}
return
Response
::
success
(
$data
);
}
}
...
...
app/Models/Collect.php
View file @
ae5cf56
...
...
@@ -44,4 +44,9 @@ class Collect extends Model
return
false
;
}
}
public
function
immerse
()
{
return
$this
->
belongsTo
(
Immerse
::
class
,
'immerse_id'
,
'id'
);
}
}
...
...
Please
register
or
login
to post a comment