mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-12-25 06:23:18 +00:00
Update CollectionController
This commit is contained in:
parent
64926762f2
commit
6791d13fc5
1 changed files with 31 additions and 0 deletions
|
@ -167,4 +167,35 @@ class CollectionController extends Controller
|
||||||
|
|
||||||
return response()->json($res);
|
return response()->json($res);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getUserCollections(Request $request, int $id)
|
||||||
|
{
|
||||||
|
$profile = Profile::whereNull('status')
|
||||||
|
->whereNull('domain')
|
||||||
|
->findOrFail($id);
|
||||||
|
|
||||||
|
if($profile->is_private) {
|
||||||
|
abort_if(!Auth::check(), 404);
|
||||||
|
abort_if(!$profile->followedBy(Auth::user()->profile) && $profile->id != Auth::user()->profile_id, 404);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $profile
|
||||||
|
->collections()
|
||||||
|
->has('posts')
|
||||||
|
->with('posts')
|
||||||
|
->whereVisibility('public')
|
||||||
|
->whereNotNull('published_at')
|
||||||
|
->orderByDesc('published_at')
|
||||||
|
->paginate(9)
|
||||||
|
->map(function($collection) {
|
||||||
|
return [
|
||||||
|
'id' => $collection->id,
|
||||||
|
'title' => $collection->title,
|
||||||
|
'description' => $collection->description,
|
||||||
|
'thumb' => $collection->posts()->first()->thumb(),
|
||||||
|
'url' => $collection->url(),
|
||||||
|
'published_at' => $collection->published_at
|
||||||
|
];
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue