1
0
Fork 1
mirror of https://github.com/pixelfed/pixelfed.git synced 2024-12-30 19:55:10 +00:00
pixelfed/app/Services/AccountService.php

29 lines
707 B
PHP
Raw Normal View History

2019-11-23 05:34:56 +00:00
<?php
namespace App\Services;
use Cache;
use App\Profile;
use App\Transformer\Api\AccountTransformer;
use League\Fractal;
use League\Fractal\Serializer\ArraySerializer;
class AccountService {
const CACHE_KEY = 'pf:services:account:';
public static function get($id)
{
2019-11-28 02:20:41 +00:00
// $key = self::CACHE_KEY . ':' . $id;
// $ttl = now()->addSeconds(10);
// return Cache::remember($key, $ttl, function() use($id) {
// });
$fractal = new Fractal\Manager();
$fractal->setSerializer(new ArraySerializer());
$profile = Profile::whereNull('status')->findOrFail($id);
$resource = new Fractal\Resource\Item($profile, new AccountTransformer());
return $fractal->createData($resource)->toArray();
2019-11-23 05:34:56 +00:00
}
}