Просмотр исходного кода

Update BaseApiController, add source to verify_credentials endpoint

Daniel Supernault 5 лет назад
Родитель
Сommit
043b3b51dd
1 измененных файлов с 9 добавлено и 1 удалено
  1. 9 1
      app/Http/Controllers/Api/BaseApiController.php

+ 9 - 1
app/Http/Controllers/Api/BaseApiController.php

@@ -306,7 +306,15 @@ class BaseApiController extends Controller
         $res = Cache::remember('user:account:id:'.$id, now()->addHours(6), function() use($id) {
             $profile = Profile::whereNull('status')->whereUserId($id)->firstOrFail();
             $resource = new Fractal\Resource\Item($profile, new AccountTransformer());
-            return $this->fractal->createData($resource)->toArray();
+            $res = $this->fractal->createData($resource)->toArray();
+            $res['source'] = [
+                'privacy' => $profile->is_private ? 'private' : 'public',
+                'sensitive' => $profile->cw ? true : false,
+                'language' => 'en',
+                'note' => '',
+                'fields' => []
+            ];
+            return $res;
         });
 
         return response()->json($res);