From 11cd75e8e84a2a021d0a5d473d88aaecb454c8c5 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Thu, 26 Sep 2019 20:49:44 -0600 Subject: [PATCH] Update ApiController --- app/Http/Controllers/Api/ApiV1Controller.php | 37 ++++++++++++-------- 1 file changed, 23 insertions(+), 14 deletions(-) diff --git a/app/Http/Controllers/Api/ApiV1Controller.php b/app/Http/Controllers/Api/ApiV1Controller.php index 88becd0f4..e4020228c 100644 --- a/app/Http/Controllers/Api/ApiV1Controller.php +++ b/app/Http/Controllers/Api/ApiV1Controller.php @@ -200,14 +200,18 @@ class ApiV1Controller extends Controller abort_if(!$request->user(), 403); $profile = Profile::whereNull('status')->findOrFail($id); - $settings = $profile->user->settings; - if($settings->show_profile_followers == true) { - $limit = $request->input('limit') ?? 40; - $followers = $profile->followers()->paginate($limit); - $resource = new Fractal\Resource\Collection($followers, new AccountTransformer()); - $res = $this->fractal->createData($resource)->toArray(); - } else { + if($profile->domain) { $res = []; + } else { + $settings = $profile->user->settings; + if($settings->show_profile_followers == true) { + $limit = $request->input('limit') ?? 40; + $followers = $profile->followers()->paginate($limit); + $resource = new Fractal\Resource\Collection($followers, new AccountTransformer()); + $res = $this->fractal->createData($resource)->toArray(); + } else { + $res = []; + } } return response()->json($res); } @@ -224,15 +228,20 @@ class ApiV1Controller extends Controller abort_if(!$request->user(), 403); $profile = Profile::whereNull('status')->findOrFail($id); - $settings = $profile->user->settings; - if($settings->show_profile_following == true) { - $limit = $request->input('limit') ?? 40; - $following = $profile->following()->paginate($limit); - $resource = new Fractal\Resource\Collection($following, new AccountTransformer()); - $res = $this->fractal->createData($resource)->toArray(); - } else { + if($profile->domain) { $res = []; + } else { + $settings = $profile->user->settings; + if($settings->show_profile_following == true) { + $limit = $request->input('limit') ?? 40; + $following = $profile->following()->paginate($limit); + $resource = new Fractal\Resource\Collection($following, new AccountTransformer()); + $res = $this->fractal->createData($resource)->toArray(); + } else { + $res = []; + } } + return response()->json($res); }