From 9bbbd1116052e68ae5ac0a596234969262507783 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Sun, 10 Feb 2019 13:42:26 -0700 Subject: [PATCH] Update PublicApiController --- app/Http/Controllers/PublicApiController.php | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/app/Http/Controllers/PublicApiController.php b/app/Http/Controllers/PublicApiController.php index b38bedfc..61e9e657 100644 --- a/app/Http/Controllers/PublicApiController.php +++ b/app/Http/Controllers/PublicApiController.php @@ -19,6 +19,7 @@ use Carbon\Carbon; use League\Fractal; use App\Transformer\Api\{ AccountTransformer, + RelationshipTransformer, StatusTransformer, }; use App\Jobs\StatusPipeline\NewStatusPipeline; @@ -330,4 +331,21 @@ class PublicApiController extends Controller return response()->json($res); } + + public function relationships(Request $request) + { + abort_if(!Auth::check(), 403); + + $this->validate($request, [ + 'id' => 'required|array|min:1|max:20' + ]); + $ids = collect($request->input('id')); + $filtered = $ids->filter(function($v) { + return $v != Auth::user()->profile->id; + }); + $relations = Profile::findOrFail($filtered->all()); + $fractal = new Fractal\Resource\Collection($relations, new RelationshipTransformer()); + $res = $this->fractal->createData($fractal)->toArray(); + return response()->json($res); + } }