. */ declare(strict_types=1); namespace FireflyIII\Transformers; use FireflyIII\Models\Budget; use League\Fractal\TransformerAbstract; use Symfony\Component\HttpFoundation\ParameterBag; /** * Class BudgetTransformer */ class BudgetTransformer extends TransformerAbstract { /** * List of resources possible to include * * @var array */ protected $availableIncludes = ['user', 'transactions']; /** * List of resources to automatically include * * @var array */ protected $defaultIncludes = []; /** @var ParameterBag */ protected $parameters; /** * BillTransformer constructor. * * @param ParameterBag $parameters */ public function __construct(ParameterBag $parameters) { $this->parameters = $parameters; } /** * @param Budget $budget * * @return array */ public function transform(Budget $budget): array { $data = [ 'id' => (int)$budget->id, 'updated_at' => $budget->updated_at->toAtomString(), 'created_at' => $budget->created_at->toAtomString(), 'name' => $budget->name, 'links' => [ [ 'rel' => 'self', 'uri' => '/budgets/' . $budget->id, ], ], ]; return $data; } }