Update ApiController

This commit is contained in:
Daniel Supernault 2019-09-26 20:49:44 -06:00
parent 43c18e866c
commit 11cd75e8e8
No known key found for this signature in database
GPG key ID: 0DEF1C662C9033F7

View file

@ -200,14 +200,18 @@ class ApiV1Controller extends Controller
abort_if(!$request->user(), 403); abort_if(!$request->user(), 403);
$profile = Profile::whereNull('status')->findOrFail($id); $profile = Profile::whereNull('status')->findOrFail($id);
$settings = $profile->user->settings; if($profile->domain) {
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 = []; $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); return response()->json($res);
} }
@ -224,15 +228,20 @@ class ApiV1Controller extends Controller
abort_if(!$request->user(), 403); abort_if(!$request->user(), 403);
$profile = Profile::whereNull('status')->findOrFail($id); $profile = Profile::whereNull('status')->findOrFail($id);
$settings = $profile->user->settings; if($profile->domain) {
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 = []; $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); return response()->json($res);
} }