From bfa04b7ad792d2e18b4d2d15c0ccda320ce813d8 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Fri, 31 Aug 2018 18:54:50 -0600 Subject: [PATCH] Update BaseApiController@accountStatuses, handle visibility scope properly --- app/Http/Controllers/Api/BaseApiController.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/app/Http/Controllers/Api/BaseApiController.php b/app/Http/Controllers/Api/BaseApiController.php index 04be48af..f55c15ce 100644 --- a/app/Http/Controllers/Api/BaseApiController.php +++ b/app/Http/Controllers/Api/BaseApiController.php @@ -57,8 +57,14 @@ class BaseApiController extends Controller public function accountStatuses(Request $request, $id) { + $pid = Auth::user()->profile->id; $profile = Profile::findOrFail($id); - $statuses = $profile->statuses()->orderBy('id', 'desc')->paginate(20); + $statuses = $profile->statuses(); + if($pid === $profile->id) { + $statuses = $statuses->orderBy('id', 'desc')->paginate(20); + } else { + $statuses = $statuses->whereVisibility('public')->orderBy('id', 'desc')->paginate(20); + } $resource = new Fractal\Resource\Collection($statuses, new StatusTransformer()); $res = $this->fractal->createData($resource)->toArray();