Update ApiController

This commit is contained in:
Daniel Supernault 2019-09-13 21:48:16 -06:00
parent 505b9ee732
commit ec24dec2df
No known key found for this signature in database
GPG key ID: 0DEF1C662C9033F7

View file

@ -8,18 +8,32 @@ use Illuminate\Support\Str;
use App\Jobs\StatusPipeline\StatusDelete; use App\Jobs\StatusPipeline\StatusDelete;
use Laravel\Passport\Passport; use Laravel\Passport\Passport;
use Auth, Cache, DB; use Auth, Cache, DB;
use Carbon\Carbon;
use App\{ use App\{
Like, Like,
Media, Media,
Profile, Profile,
Status Status
}; };
use League\Fractal;
use App\Transformer\Api\{
AccountTransformer,
RelationshipTransformer,
StatusTransformer,
};
use League\Fractal\Serializer\ArraySerializer;
use League\Fractal\Pagination\IlluminatePaginatorAdapter;
use App\Services\NotificationService; use App\Services\NotificationService;
class ApiV1Controller extends Controller { class ApiV1Controller extends Controller
{
protected $fractal;
public function __construct()
{
$this->fractal = new Fractal\Manager();
$this->fractal->setSerializer(new ArraySerializer());
}
public function apps(Request $request) public function apps(Request $request)
{ {
abort_if(!config('pixelfed.oauth_enabled'), 404); abort_if(!config('pixelfed.oauth_enabled'), 404);
@ -54,4 +68,13 @@ class ApiV1Controller extends Controller {
]; ];
return $res; return $res;
} }
public function accountById(Request $request, $id)
{
$profile = Profile::whereNull('status')->findOrFail($id);
$resource = new Fractal\Resource\Item($profile, new AccountTransformer());
$res = $this->fractal->createData($resource)->toArray();
return response()->json($res);
}
} }