From 59f8292e073e1463afb84615ecce41791d4be8ba Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Sun, 9 Dec 2018 16:02:32 -0700 Subject: [PATCH] Update InternalApiController --- app/Http/Controllers/InternalApiController.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/app/Http/Controllers/InternalApiController.php b/app/Http/Controllers/InternalApiController.php index d21b8eaba..fbab7a46a 100644 --- a/app/Http/Controllers/InternalApiController.php +++ b/app/Http/Controllers/InternalApiController.php @@ -288,4 +288,19 @@ class InternalApiController extends Controller return; } + + public function statusReplies(Request $request, int $id) + { + $parent = Status::findOrFail($id); + + $children = Status::whereInReplyToId($parent->id) + ->orderBy('created_at', 'desc') + ->take(3) + ->get(); + + $resource = new Fractal\Resource\Collection($children, new StatusTransformer()); + $res = $this->fractal->createData($resource)->toArray(); + + return response()->json($res); + } }