mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
Expanded API code, wrote a bunch new transformers as well.
This commit is contained in:
parent
94f6bd34c7
commit
c2da5931ec
@ -88,22 +88,19 @@ class AccountController extends Controller
|
||||
*/
|
||||
public function index(Request $request)
|
||||
{
|
||||
$type = $request->get('type') ?? 'all';
|
||||
$types = $this->mapTypes($type);
|
||||
$types = $this->mapTypes($this->parameters->get('type'));
|
||||
$pageSize = intval(Preferences::getForUser(auth()->user(), 'listPageSize', 50)->data);
|
||||
$page = 0 === intval($request->get('page')) ? 1 : intval($request->get('page'));
|
||||
$collection = $this->repository->getAccountsByType($types);
|
||||
$count = $collection->count();
|
||||
$accounts = $collection->slice(($page - 1) * $pageSize, $pageSize);
|
||||
$accounts = $collection->slice(($this->parameters->get('page') - 1) * $pageSize, $pageSize);
|
||||
|
||||
// make paginator:
|
||||
$paginator = new LengthAwarePaginator($accounts, $count, $pageSize, $page);
|
||||
|
||||
$manager = new Manager();
|
||||
$baseUrl = $request->getSchemeAndHttpHost() . '/api/v1';
|
||||
$paginator = new LengthAwarePaginator($accounts, $count, $pageSize, $this->parameters->get('page'));
|
||||
$manager = new Manager();
|
||||
$baseUrl = $request->getSchemeAndHttpHost() . '/api/v1';
|
||||
$manager->setSerializer(new JsonApiSerializer($baseUrl));
|
||||
|
||||
$resource = new FractalCollection($accounts, new AccountTransformer, 'accounts');
|
||||
$resource = new FractalCollection($accounts, new AccountTransformer($this->parameters), 'accounts');
|
||||
$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));
|
||||
|
||||
return Response::json($manager->createData($resource)->toArray());
|
||||
@ -119,10 +116,10 @@ class AccountController extends Controller
|
||||
{
|
||||
|
||||
$manager = new Manager();
|
||||
$manager->parseIncludes(['attachments', 'journals', 'user']);
|
||||
//$manager->parseIncludes(['attachments', 'journals', 'user']);
|
||||
$baseUrl = $request->getSchemeAndHttpHost() . '/api/v1';
|
||||
$manager->setSerializer(new JsonApiSerializer($baseUrl));
|
||||
$resource = new Item($account, new AccountTransformer, 'accounts');
|
||||
$resource = new Item($account, new AccountTransformer($this->parameters), 'accounts');
|
||||
|
||||
return Response::json($manager->createData($resource)->toArray());
|
||||
}
|
||||
|
@ -22,7 +22,6 @@ declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Api\V1\Controllers;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use FireflyIII\Api\V1\Requests\BillRequest;
|
||||
use FireflyIII\Models\Bill;
|
||||
use FireflyIII\Repositories\Bill\BillRepositoryInterface;
|
||||
@ -87,15 +86,7 @@ class BillController extends Controller
|
||||
*/
|
||||
public function index(Request $request)
|
||||
{
|
||||
$pageSize = intval(Preferences::getForUser(auth()->user(), 'listPageSize', 50)->data);
|
||||
$start = null;
|
||||
$end = null;
|
||||
if (null !== $request->get('start')) {
|
||||
$start = new Carbon($request->get('start'));
|
||||
}
|
||||
if (null !== $request->get('end')) {
|
||||
$end = new Carbon($request->get('end'));
|
||||
}
|
||||
$pageSize = intval(Preferences::getForUser(auth()->user(), 'listPageSize', 50)->data);
|
||||
$paginator = $this->repository->getPaginator($pageSize);
|
||||
/** @var Collection $bills */
|
||||
$bills = $paginator->getCollection();
|
||||
@ -104,7 +95,7 @@ class BillController extends Controller
|
||||
$baseUrl = $request->getSchemeAndHttpHost() . '/api/v1';
|
||||
$manager->setSerializer(new JsonApiSerializer($baseUrl));
|
||||
|
||||
$resource = new FractalCollection($bills, new BillTransformer($start, $end), 'bills');
|
||||
$resource = new FractalCollection($bills, new BillTransformer($this->parameters), 'bills');
|
||||
$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));
|
||||
|
||||
return Response::json($manager->createData($resource)->toArray());
|
||||
@ -119,22 +110,12 @@ class BillController extends Controller
|
||||
*/
|
||||
public function show(Request $request, Bill $bill)
|
||||
{
|
||||
$start = null;
|
||||
$end = null;
|
||||
if (null !== $request->get('start')) {
|
||||
$start = new Carbon($request->get('start'));
|
||||
}
|
||||
if (null !== $request->get('end')) {
|
||||
$end = new Carbon($request->get('end'));
|
||||
}
|
||||
|
||||
|
||||
$manager = new Manager();
|
||||
$manager->parseIncludes(['attachments', 'journals', 'user']);
|
||||
$baseUrl = $request->getSchemeAndHttpHost() . '/api/v1';
|
||||
$manager->setSerializer(new JsonApiSerializer($baseUrl));
|
||||
|
||||
$resource = new Item($bill, new BillTransformer($start, $end), 'bills');
|
||||
$resource = new Item($bill, new BillTransformer($this->parameters), 'bills');
|
||||
|
||||
return Response::json($manager->createData($resource)->toArray());
|
||||
}
|
||||
@ -146,21 +127,12 @@ class BillController extends Controller
|
||||
*/
|
||||
public function store(BillRequest $request)
|
||||
{
|
||||
$start = null;
|
||||
$end = null;
|
||||
if (null !== $request->get('start')) {
|
||||
$start = new Carbon($request->get('start'));
|
||||
}
|
||||
if (null !== $request->get('end')) {
|
||||
$end = new Carbon($request->get('end'));
|
||||
}
|
||||
|
||||
$bill = $this->repository->store($request->getAll());
|
||||
$manager = new Manager();
|
||||
$baseUrl = $request->getSchemeAndHttpHost() . '/api/v1';
|
||||
$manager->setSerializer(new JsonApiSerializer($baseUrl));
|
||||
|
||||
$resource = new Item($bill, new BillTransformer($start, $end), 'bills');
|
||||
$resource = new Item($bill, new BillTransformer($this->parameters), 'bills');
|
||||
|
||||
return Response::json($manager->createData($resource)->toArray());
|
||||
|
||||
@ -175,23 +147,13 @@ class BillController extends Controller
|
||||
*/
|
||||
public function update(BillRequest $request, Bill $bill)
|
||||
{
|
||||
$data = $request->getAll();
|
||||
$bill = $this->repository->update($bill, $data);
|
||||
|
||||
$start = null;
|
||||
$end = null;
|
||||
if (null !== $request->get('start')) {
|
||||
$start = new Carbon($request->get('start'));
|
||||
}
|
||||
if (null !== $request->get('end')) {
|
||||
$end = new Carbon($request->get('end'));
|
||||
}
|
||||
|
||||
$data = $request->getAll();
|
||||
$bill = $this->repository->update($bill, $data);
|
||||
$manager = new Manager();
|
||||
$baseUrl = $request->getSchemeAndHttpHost() . '/api/v1';
|
||||
$manager->setSerializer(new JsonApiSerializer($baseUrl));
|
||||
|
||||
$resource = new Item($bill, new BillTransformer($start, $end), 'bills');
|
||||
$resource = new Item($bill, new BillTransformer($this->parameters), 'bills');
|
||||
|
||||
return Response::json($manager->createData($resource)->toArray());
|
||||
|
||||
|
@ -22,12 +22,15 @@ declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Api\V1\Controllers;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Carbon\Exceptions\InvalidDateException;
|
||||
use FireflyConfig;
|
||||
use FireflyIII\Exceptions\FireflyException;
|
||||
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
|
||||
use Illuminate\Foundation\Bus\DispatchesJobs;
|
||||
use Illuminate\Foundation\Validation\ValidatesRequests;
|
||||
use Illuminate\Routing\Controller as BaseController;
|
||||
use Symfony\Component\HttpFoundation\ParameterBag;
|
||||
|
||||
/**
|
||||
* Class Controller.
|
||||
@ -36,6 +39,9 @@ class Controller extends BaseController
|
||||
{
|
||||
use AuthorizesRequests, DispatchesJobs, ValidatesRequests;
|
||||
|
||||
/** @var ParameterBag */
|
||||
protected $parameters;
|
||||
|
||||
/**
|
||||
* Controller constructor.
|
||||
*
|
||||
@ -50,5 +56,49 @@ class Controller extends BaseController
|
||||
if (true === $isDemoSite) {
|
||||
throw new FireflyException('The API is not available on the demo site.');
|
||||
}
|
||||
|
||||
// get global parameters
|
||||
$this->parameters = $this->getParameters();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return ParameterBag
|
||||
*/
|
||||
private function getParameters(): ParameterBag
|
||||
{
|
||||
$bag = new ParameterBag;
|
||||
$page = (int)request()->get('page');
|
||||
if ($page === 0) {
|
||||
$page = 1;
|
||||
}
|
||||
$bag->set('page', $page);
|
||||
|
||||
$start = request()->get('start');
|
||||
$startDate = null;
|
||||
if (!is_null($start)) {
|
||||
try {
|
||||
$startDate = new Carbon($start);
|
||||
} catch (InvalidDateException $e) {
|
||||
// don't care
|
||||
}
|
||||
}
|
||||
$bag->set('start', $startDate);
|
||||
|
||||
$end = request()->get('end');
|
||||
$endDate = null;
|
||||
if (!is_null($end)) {
|
||||
try {
|
||||
$endDate = new Carbon($end);
|
||||
} catch (InvalidDateException $e) {
|
||||
// don't care
|
||||
}
|
||||
}
|
||||
$bag->set('end', $endDate);
|
||||
|
||||
$type = request()->get('type') ?? 'all';
|
||||
$bag->set('type', $type);
|
||||
|
||||
return $bag;
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -64,7 +64,23 @@ class Handler extends ExceptionHandler
|
||||
public function render($request, Exception $exception)
|
||||
{
|
||||
if ($exception instanceof NotFoundHttpException && $request->expectsJson()) {
|
||||
return response()->json(['message' => 'Not found'], 404);
|
||||
return response()->json(['message' => 'Resource not found', 'exception' => 'NotFoundHttpException'], 404);
|
||||
}
|
||||
if ($request->expectsJson()) {
|
||||
$isDebug = env('APP_DEBUG', false);
|
||||
if ($isDebug) {
|
||||
return response()->json(
|
||||
[
|
||||
'message' => $exception->getMessage(),
|
||||
'exception' => get_class($exception),
|
||||
'line' => $exception->getLine(),
|
||||
'file' => $exception->getFile(),
|
||||
'trace' => $exception->getTrace(),
|
||||
], 500
|
||||
);
|
||||
}
|
||||
|
||||
return response()->json(['message' => 'Internal Firefly III Exception. See log files.', 'exception' => get_class($exception)], 500);
|
||||
}
|
||||
|
||||
if ($exception instanceof FireflyException || $exception instanceof ErrorException) {
|
||||
|
@ -27,13 +27,84 @@ namespace FireflyIII\Transformers;
|
||||
use FireflyIII\Models\Account;
|
||||
use FireflyIII\Models\Note;
|
||||
use FireflyIII\Models\TransactionCurrency;
|
||||
use FireflyIII\Models\TransactionJournal;
|
||||
use League\Fractal\Resource\Collection as FractalCollection;
|
||||
use League\Fractal\Resource\Item;
|
||||
use League\Fractal\TransformerAbstract;
|
||||
use Symfony\Component\HttpFoundation\ParameterBag;
|
||||
|
||||
/**
|
||||
* Class AccountTransformer
|
||||
*/
|
||||
class AccountTransformer extends TransformerAbstract
|
||||
{
|
||||
/**
|
||||
* List of resources possible to include.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $availableIncludes = ['journals', 'piggy_banks', 'user'];
|
||||
/**
|
||||
* List of resources to automatically include
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $defaultIncludes = ['journals', 'piggy_banks', 'user'];
|
||||
/** @var ParameterBag */
|
||||
protected $parameters;
|
||||
|
||||
/**
|
||||
* BillTransformer constructor.
|
||||
*
|
||||
* @param ParameterBag $parameters
|
||||
*/
|
||||
public function __construct(ParameterBag $parameters)
|
||||
{
|
||||
$this->parameters = $parameters;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Account $account
|
||||
*
|
||||
* @return FractalCollection
|
||||
*/
|
||||
public function includeJournals(Account $account): FractalCollection
|
||||
{
|
||||
$ids = $account->transactions()->get(['transactions.transaction_journal_id'])->pluck('transaction_journal_id')->toArray();
|
||||
$query = TransactionJournal::whereIn('id', $ids);
|
||||
if (!is_null($this->parameters->get('end'))) {
|
||||
$query->where('date', '<=', $this->parameters->get('end')->format('Y-m-d 00:00:00'));
|
||||
}
|
||||
if (!is_null($this->parameters->get('start'))) {
|
||||
$query->where('date', '>=', $this->parameters->get('start')->format('Y-m-d 00:00:00'));
|
||||
}
|
||||
|
||||
$journals = $query->get(['transaction_journals.*']);
|
||||
return $this->collection($journals, new TransactionJournalTransformer($this->parameters), 'journals');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Account $account
|
||||
*
|
||||
* @return FractalCollection
|
||||
*/
|
||||
public function includePiggyBanks(Account $account): FractalCollection
|
||||
{
|
||||
$piggies = $account->piggyBanks()->get();
|
||||
|
||||
return $this->collection($piggies, new PiggyBankTransformer($this->parameters), 'piggy_banks');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Account $account
|
||||
*
|
||||
* @return Item
|
||||
*/
|
||||
public function includeUser(Account $account): Item
|
||||
{
|
||||
return $this->item($account->user, new UserTransformer($this->parameters), 'user');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Account $account
|
||||
*
|
||||
@ -58,17 +129,22 @@ class AccountTransformer extends TransformerAbstract
|
||||
|
||||
|
||||
$data = [
|
||||
'id' => (int)$account->id,
|
||||
'updated_at' => $account->updated_at->toAtomString(),
|
||||
'created_at' => $account->created_at->toAtomString(),
|
||||
'name' => $account->name,
|
||||
'active' => intval($account->active) === 1,
|
||||
'type' => $account->accountType->type,
|
||||
'currency_id' => $currencyId,
|
||||
'currency_code' => $currencyCode,
|
||||
'notes' => null,
|
||||
'role' => $role,
|
||||
'links' => [
|
||||
'id' => (int)$account->id,
|
||||
'updated_at' => $account->updated_at->toAtomString(),
|
||||
'created_at' => $account->created_at->toAtomString(),
|
||||
'name' => $account->name,
|
||||
'active' => intval($account->active) === 1,
|
||||
'type' => $account->accountType->type,
|
||||
'currency_id' => $currencyId,
|
||||
'currency_code' => $currencyCode,
|
||||
'notes' => null,
|
||||
'monthly_payment_date' => $this->getMeta($account, 'ccMonthlyPaymentDate'),
|
||||
'credit_card_type' => $this->getMeta($account, 'ccType'),
|
||||
'account_number' => $this->getMeta($account, 'accountNumber'),
|
||||
'iban' => $account->iban,
|
||||
'bic' => $this->getMeta($account, 'BIC'),
|
||||
'role' => $role,
|
||||
'links' => [
|
||||
[
|
||||
'rel' => 'self',
|
||||
'uri' => '/accounts/' . $account->id,
|
||||
@ -84,4 +160,20 @@ class AccountTransformer extends TransformerAbstract
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Account $account
|
||||
* @param string $field
|
||||
*
|
||||
* @return null|string
|
||||
*/
|
||||
private function getMeta(Account $account, string $field): ?string
|
||||
{
|
||||
$result = $account->getMeta($field);
|
||||
if (strlen($result) === 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
}
|
@ -27,6 +27,7 @@ namespace FireflyIII\Transformers;
|
||||
use FireflyIII\Models\Attachment;
|
||||
use League\Fractal\Resource\Item;
|
||||
use League\Fractal\TransformerAbstract;
|
||||
use Symfony\Component\HttpFoundation\ParameterBag;
|
||||
|
||||
/**
|
||||
* Class AttachmentTransformer
|
||||
@ -44,7 +45,20 @@ class AttachmentTransformer extends TransformerAbstract
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $defaultIncludes = [];
|
||||
protected $defaultIncludes = ['user'];
|
||||
|
||||
/** @var ParameterBag */
|
||||
protected $parameters;
|
||||
|
||||
/**
|
||||
* BillTransformer constructor.
|
||||
*
|
||||
* @param ParameterBag $parameters
|
||||
*/
|
||||
public function __construct(ParameterBag $parameters)
|
||||
{
|
||||
$this->parameters = $parameters;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Attachment $attachment
|
||||
@ -53,9 +67,7 @@ class AttachmentTransformer extends TransformerAbstract
|
||||
*/
|
||||
public function includeUser(Attachment $attachment): Item
|
||||
{
|
||||
$user = $attachment->user()->first();
|
||||
|
||||
return $this->item($user, new UserTransformer, 'user');
|
||||
return $this->item($attachment->user, new UserTransformer($this->parameters), 'user');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -31,6 +31,7 @@ use Illuminate\Support\Collection;
|
||||
use League\Fractal\Resource\Collection as FractalCollection;
|
||||
use League\Fractal\Resource\Item;
|
||||
use League\Fractal\TransformerAbstract;
|
||||
use Symfony\Component\HttpFoundation\ParameterBag;
|
||||
|
||||
/**
|
||||
* Class BillTransformer
|
||||
@ -49,21 +50,18 @@ class BillTransformer extends TransformerAbstract
|
||||
* @var array
|
||||
*/
|
||||
protected $defaultIncludes = [];
|
||||
/** @var Carbon */
|
||||
private $end = null;
|
||||
/** @var Carbon */
|
||||
private $start = null;
|
||||
|
||||
/** @var ParameterBag */
|
||||
protected $parameters;
|
||||
|
||||
/**
|
||||
* BillTransformer constructor.
|
||||
*
|
||||
* @param Carbon|null $start
|
||||
* @param Carbon|null $end
|
||||
* @param ParameterBag $parameters
|
||||
*/
|
||||
public function __construct(Carbon $start = null, Carbon $end = null)
|
||||
public function __construct(ParameterBag $parameters)
|
||||
{
|
||||
$this->start = $start;
|
||||
$this->end = $end;
|
||||
$this->parameters = $parameters;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -75,7 +73,7 @@ class BillTransformer extends TransformerAbstract
|
||||
{
|
||||
$attachments = $bill->attachments()->get();
|
||||
|
||||
return $this->collection($attachments, new AttachmentTransformer, 'attachments');
|
||||
return $this->collection($attachments, new AttachmentTransformer($this->parameters), 'attachments');
|
||||
}
|
||||
|
||||
/**
|
||||
@ -85,9 +83,16 @@ class BillTransformer extends TransformerAbstract
|
||||
*/
|
||||
public function includeJournals(Bill $bill): FractalCollection
|
||||
{
|
||||
$journals = $bill->transactionJournals()->get();
|
||||
$query = $bill->transactionJournals();
|
||||
if (!is_null($this->parameters->get('end'))) {
|
||||
$query->where('date', '<=', $this->parameters->get('end')->format('Y-m-d 00:00:00'));
|
||||
}
|
||||
if (!is_null($this->parameters->get('start'))) {
|
||||
$query->where('date', '>=', $this->parameters->get('start')->format('Y-m-d 00:00:00'));
|
||||
}
|
||||
$journals = $query->get();
|
||||
|
||||
return $this->collection($journals, new TransactionJournalTransformer, 'journals');
|
||||
return $this->collection($journals, new TransactionJournalTransformer($this->parameters), 'journals');
|
||||
}
|
||||
|
||||
/**
|
||||
@ -97,9 +102,7 @@ class BillTransformer extends TransformerAbstract
|
||||
*/
|
||||
public function includeUser(Bill $bill): Item
|
||||
{
|
||||
$user = $bill->user()->first();
|
||||
|
||||
return $this->item($user, new UserTransformer, 'users');
|
||||
return $this->item($bill->user, new UserTransformer($this->parameters), 'users');
|
||||
}
|
||||
|
||||
/**
|
||||
@ -196,7 +199,7 @@ class BillTransformer extends TransformerAbstract
|
||||
*/
|
||||
protected function paidData(Bill $bill): array
|
||||
{
|
||||
if (is_null($this->start) || is_null($this->end)) {
|
||||
if (is_null($this->parameters->get('start')) || is_null($this->parameters->get('end'))) {
|
||||
return [
|
||||
'paid_dates' => [],
|
||||
'next_expected_match' => null,
|
||||
@ -206,7 +209,7 @@ class BillTransformer extends TransformerAbstract
|
||||
/** @var BillRepositoryInterface $repository */
|
||||
$repository = app(BillRepositoryInterface::class);
|
||||
$repository->setUser($bill->user);
|
||||
$set = $repository->getPaidDatesInRange($bill, $this->start, $this->end);
|
||||
$set = $repository->getPaidDatesInRange($bill, $this->parameters->get('start'), $this->parameters->get('end'));
|
||||
$simple = $set->map(
|
||||
function (Carbon $date) {
|
||||
return $date->format('Y-m-d');
|
||||
@ -214,7 +217,7 @@ class BillTransformer extends TransformerAbstract
|
||||
);
|
||||
|
||||
// calculate next expected match:
|
||||
$lastPaidDate = $this->lastPaidDate($set, $this->start);
|
||||
$lastPaidDate = $this->lastPaidDate($set, $this->parameters->get('start'));
|
||||
$nextMatch = clone $bill->date;
|
||||
while ($nextMatch < $lastPaidDate) {
|
||||
$nextMatch = app('navigation')->addPeriod($nextMatch, $bill->repeat_freq, $bill->skip);
|
||||
@ -238,15 +241,15 @@ class BillTransformer extends TransformerAbstract
|
||||
*/
|
||||
protected function payDates(Bill $bill): array
|
||||
{
|
||||
if (is_null($this->start) || is_null($this->end)) {
|
||||
if (is_null($this->parameters->get('start')) || is_null($this->parameters->get('end'))) {
|
||||
return [];
|
||||
}
|
||||
$set = new Collection;
|
||||
$currentStart = clone $this->start;
|
||||
while ($currentStart <= $this->end) {
|
||||
$currentStart = clone $this->parameters->get('start');
|
||||
while ($currentStart <= $this->parameters->get('end')) {
|
||||
$nextExpectedMatch = $this->nextDateMatch($bill, $currentStart);
|
||||
// If nextExpectedMatch is after end, we continue:
|
||||
if ($nextExpectedMatch > $this->end) {
|
||||
if ($nextExpectedMatch > $this->parameters->get('end')) {
|
||||
break;
|
||||
}
|
||||
// add to set
|
||||
|
85
app/Transformers/BudgetTransformer.php
Normal file
85
app/Transformers/BudgetTransformer.php
Normal file
@ -0,0 +1,85 @@
|
||||
<?php
|
||||
/**
|
||||
* BudgetTransformer.php
|
||||
* Copyright (c) 2018 thegrumpydictator@gmail.com
|
||||
*
|
||||
* This file is part of Firefly III.
|
||||
*
|
||||
* Firefly III is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Firefly III is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
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'];
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
|
||||
}
|
85
app/Transformers/CategoryTransformer.php
Normal file
85
app/Transformers/CategoryTransformer.php
Normal file
@ -0,0 +1,85 @@
|
||||
<?php
|
||||
/**
|
||||
* CategoryTransformer.php
|
||||
* Copyright (c) 2018 thegrumpydictator@gmail.com
|
||||
*
|
||||
* This file is part of Firefly III.
|
||||
*
|
||||
* Firefly III is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Firefly III is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Transformers;
|
||||
|
||||
|
||||
use FireflyIII\Models\Category;
|
||||
use League\Fractal\TransformerAbstract;
|
||||
use Symfony\Component\HttpFoundation\ParameterBag;
|
||||
|
||||
/**
|
||||
* Class CategoryTransformer
|
||||
*/
|
||||
class CategoryTransformer extends TransformerAbstract
|
||||
{
|
||||
/**
|
||||
* List of resources possible to include
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $availableIncludes = ['user'];
|
||||
/**
|
||||
* 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 Category $category
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function transform(Category $category): array
|
||||
{
|
||||
$data = [
|
||||
'id' => (int)$category->id,
|
||||
'updated_at' => $category->updated_at->toAtomString(),
|
||||
'created_at' => $category->created_at->toAtomString(),
|
||||
'name' => $category->name,
|
||||
'links' => [
|
||||
[
|
||||
'rel' => 'self',
|
||||
'uri' => '/categories/' . $category->id,
|
||||
],
|
||||
],
|
||||
];
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
}
|
87
app/Transformers/JournalMetaTransformer.php
Normal file
87
app/Transformers/JournalMetaTransformer.php
Normal file
@ -0,0 +1,87 @@
|
||||
<?php
|
||||
/**
|
||||
* JournalMetaTransformer.php
|
||||
* Copyright (c) 2018 thegrumpydictator@gmail.com
|
||||
*
|
||||
* This file is part of Firefly III.
|
||||
*
|
||||
* Firefly III is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Firefly III is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Transformers;
|
||||
|
||||
|
||||
use FireflyIII\Models\TransactionJournalMeta;
|
||||
use League\Fractal\TransformerAbstract;
|
||||
use Symfony\Component\HttpFoundation\ParameterBag;
|
||||
|
||||
/**
|
||||
* Class JournalMetaTransformer
|
||||
*/
|
||||
class JournalMetaTransformer extends TransformerAbstract
|
||||
{
|
||||
/**
|
||||
* List of resources possible to include
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $availableIncludes = ['journal'];
|
||||
/**
|
||||
* 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 TransactionJournalMeta $meta
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function transform(TransactionJournalMeta $meta): array
|
||||
{
|
||||
$data = [
|
||||
'id' => (int)$meta->id,
|
||||
'updated_at' => $meta->updated_at->toAtomString(),
|
||||
'created_at' => $meta->created_at->toAtomString(),
|
||||
'name' => $meta->name,
|
||||
'data' => $meta->data,
|
||||
'hash' => $meta->hash,
|
||||
'links' => [
|
||||
[
|
||||
'rel' => 'self',
|
||||
'uri' => '/journal_meta/' . $meta->id,
|
||||
],
|
||||
],
|
||||
];
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
}
|
85
app/Transformers/PiggyBankEventTransformer.php
Normal file
85
app/Transformers/PiggyBankEventTransformer.php
Normal file
@ -0,0 +1,85 @@
|
||||
<?php
|
||||
/**
|
||||
* PiggyBankEventTransformer.php
|
||||
* Copyright (c) 2018 thegrumpydictator@gmail.com
|
||||
*
|
||||
* This file is part of Firefly III.
|
||||
*
|
||||
* Firefly III is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Firefly III is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Transformers;
|
||||
|
||||
|
||||
use FireflyIII\Models\PiggyBankEvent;
|
||||
use League\Fractal\TransformerAbstract;
|
||||
use Symfony\Component\HttpFoundation\ParameterBag;
|
||||
|
||||
/**
|
||||
* Class PiggyBankEventTransformer
|
||||
*/
|
||||
class PiggyBankEventTransformer extends TransformerAbstract
|
||||
{
|
||||
/**
|
||||
* List of resources possible to include
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $availableIncludes = ['piggy_bank', 'journal'];
|
||||
/**
|
||||
* 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 PiggyBankEvent $event
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function transform(PiggyBankEvent $event): array
|
||||
{
|
||||
$data = [
|
||||
'id' => (int)$event->id,
|
||||
'updated_at' => $event->updated_at->toAtomString(),
|
||||
'created_at' => $event->created_at->toAtomString(),
|
||||
'amount' => $event->amount,
|
||||
'links' => [
|
||||
[
|
||||
'rel' => 'self',
|
||||
'uri' => '/piggy_bank_events/' . $event->id,
|
||||
],
|
||||
],
|
||||
];
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
}
|
92
app/Transformers/PiggyBankTransformer.php
Normal file
92
app/Transformers/PiggyBankTransformer.php
Normal file
@ -0,0 +1,92 @@
|
||||
<?php
|
||||
/**
|
||||
* PiggyBankTransformer.php
|
||||
* Copyright (c) 2018 thegrumpydictator@gmail.com
|
||||
*
|
||||
* This file is part of Firefly III.
|
||||
*
|
||||
* Firefly III is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Firefly III is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Transformers;
|
||||
|
||||
|
||||
use FireflyIII\Models\Note;
|
||||
use FireflyIII\Models\PiggyBank;
|
||||
use League\Fractal\TransformerAbstract;
|
||||
use Symfony\Component\HttpFoundation\ParameterBag;
|
||||
|
||||
/**
|
||||
* Class PiggyBankTransformer
|
||||
*/
|
||||
class PiggyBankTransformer extends TransformerAbstract
|
||||
{
|
||||
/**
|
||||
* List of resources possible to include
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $availableIncludes = ['account', 'user', 'piggy_bank_events'];
|
||||
/**
|
||||
* 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 PiggyBank $piggyBank
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function transform(PiggyBank $piggyBank): array
|
||||
{
|
||||
|
||||
$data = [
|
||||
'id' => (int)$piggyBank->id,
|
||||
'updated_at' => $piggyBank->updated_at->toAtomString(),
|
||||
'created_at' => $piggyBank->created_at->toAtomString(),
|
||||
'name' => $piggyBank->name,
|
||||
'notes' => null,
|
||||
'links' => [
|
||||
[
|
||||
'rel' => 'self',
|
||||
'uri' => '/piggy_banks/' . $piggyBank->id,
|
||||
],
|
||||
],
|
||||
];
|
||||
/** @var Note $note */
|
||||
$note = $piggyBank->notes()->first();
|
||||
if (!is_null($note)) {
|
||||
$data['notes'] = $note->text;
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
}
|
85
app/Transformers/TagTransformer.php
Normal file
85
app/Transformers/TagTransformer.php
Normal file
@ -0,0 +1,85 @@
|
||||
<?php
|
||||
/**
|
||||
* TagTransformer.php
|
||||
* Copyright (c) 2018 thegrumpydictator@gmail.com
|
||||
*
|
||||
* This file is part of Firefly III.
|
||||
*
|
||||
* Firefly III is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Firefly III is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Transformers;
|
||||
|
||||
|
||||
use FireflyIII\Models\Tag;
|
||||
use League\Fractal\TransformerAbstract;
|
||||
use Symfony\Component\HttpFoundation\ParameterBag;
|
||||
|
||||
/**
|
||||
* Class TagTransformer
|
||||
*/
|
||||
class TagTransformer extends TransformerAbstract
|
||||
{
|
||||
/**
|
||||
* List of resources possible to include
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $availableIncludes = ['user'];
|
||||
/**
|
||||
* 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 Tag $tag
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function transform(Tag $tag): array
|
||||
{
|
||||
$data = [
|
||||
'id' => (int)$tag->id,
|
||||
'updated_at' => $tag->updated_at->toAtomString(),
|
||||
'created_at' => $tag->created_at->toAtomString(),
|
||||
'tag' => $tag->tag,
|
||||
'links' => [
|
||||
[
|
||||
'rel' => 'self',
|
||||
'uri' => '/tags/' . $tag->id,
|
||||
],
|
||||
],
|
||||
];
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
}
|
@ -27,7 +27,9 @@ namespace FireflyIII\Transformers;
|
||||
use FireflyIII\Models\Note;
|
||||
use FireflyIII\Models\TransactionJournal;
|
||||
use League\Fractal\Resource\Collection as FractalCollection;
|
||||
use League\Fractal\Resource\Item;
|
||||
use League\Fractal\TransformerAbstract;
|
||||
use Symfony\Component\HttpFoundation\ParameterBag;
|
||||
|
||||
/**
|
||||
* Class TransactionJournalTransformer
|
||||
@ -40,13 +42,117 @@ class TransactionJournalTransformer extends TransformerAbstract
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $availableIncludes = ['attachments', 'transactions', 'user', 'tags', 'budget', 'category', 'bill', 'meta', 'piggy_bank_events'];
|
||||
protected $availableIncludes = ['attachments', 'transactions', 'user', 'tags', 'budget', 'category', 'bill', 'journal_meta', 'piggy_bank_events'];
|
||||
/**
|
||||
* List of resources to automatically include
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $defaultIncludes = ['transactions'];
|
||||
protected $defaultIncludes = ['attachments', 'transactions', 'user', 'tags', 'budget', 'category', 'bill', 'journal_meta', 'piggy_bank_events'];
|
||||
|
||||
/** @var ParameterBag */
|
||||
protected $parameters;
|
||||
|
||||
/**
|
||||
* BillTransformer constructor.
|
||||
*
|
||||
* @param ParameterBag $parameters
|
||||
*/
|
||||
public function __construct(ParameterBag $parameters)
|
||||
{
|
||||
$this->parameters = $parameters;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param TransactionJournal $journal
|
||||
*
|
||||
* @return FractalCollection
|
||||
*/
|
||||
public function includeAttachments(TransactionJournal $journal): FractalCollection
|
||||
{
|
||||
return $this->collection($journal->attachments, new AttachmentTransformer($this->parameters), 'attachments');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param TransactionJournal $journal
|
||||
*
|
||||
* @return Item|null
|
||||
*/
|
||||
public function includeBill(TransactionJournal $journal): ?Item
|
||||
{
|
||||
$bill = $journal->bill()->first();
|
||||
if (!is_null($bill)) {
|
||||
return $this->item($bill, new BillTransformer($this->parameters), 'bills');
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param TransactionJournal $journal
|
||||
*
|
||||
* @return Item|null
|
||||
*/
|
||||
public function includeBudget(TransactionJournal $journal): ?Item
|
||||
{
|
||||
$budget = $journal->budgets()->first();
|
||||
if (!is_null($budget)) {
|
||||
return $this->item($budget, new BudgetTransformer($this->parameters), 'budgets');
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param TransactionJournal $journal
|
||||
*
|
||||
* @return Item|null
|
||||
*/
|
||||
public function includeCategory(TransactionJournal $journal): ?Item
|
||||
{
|
||||
$category = $journal->categories()->first();
|
||||
if (!is_null($category)) {
|
||||
return $this->item($category, new CategoryTransformer($this->parameters), 'categories');
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param TransactionJournal $journal
|
||||
*
|
||||
* @return FractalCollection
|
||||
*/
|
||||
public function includeJournalMeta(TransactionJournal $journal): FractalCollection
|
||||
{
|
||||
$meta = $journal->transactionJournalMeta()->get();
|
||||
|
||||
return $this->collection($meta, new JournalMetaTransformer($this->parameters), 'journal_meta');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param TransactionJournal $journal
|
||||
*
|
||||
* @return FractalCollection
|
||||
*/
|
||||
public function includePiggyBankEvents(TransactionJournal $journal): FractalCollection
|
||||
{
|
||||
$events = $journal->piggyBankEvents()->get();
|
||||
|
||||
return $this->collection($events, new PiggyBankEventTransformer($this->parameters), 'piggy_bank_events');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param TransactionJournal $journal
|
||||
*
|
||||
* @return FractalCollection
|
||||
*/
|
||||
public function includeTags(TransactionJournal $journal): FractalCollection
|
||||
{
|
||||
$set = $journal->tags;
|
||||
|
||||
return $this->collection($set, new TagTransformer($this->parameters), 'tag');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param TransactionJournal $journal
|
||||
@ -57,9 +163,18 @@ class TransactionJournalTransformer extends TransformerAbstract
|
||||
{
|
||||
$set = $journal->transactions()->where('amount', '<', 0)->get(['transactions.*']);
|
||||
|
||||
return $this->collection($set, new TransactionTransformer, 'transactions');
|
||||
return $this->collection($set, new TransactionTransformer($this->parameters), 'transactions');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param TransactionJournal $journal
|
||||
*
|
||||
* @return \League\Fractal\Resource\Item
|
||||
*/
|
||||
public function includeUser(TransactionJournal $journal): Item
|
||||
{
|
||||
return $this->item($journal->user, new UserTransformer($this->parameters), 'users');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param TransactionJournal $journal
|
||||
|
@ -26,12 +26,26 @@ namespace FireflyIII\Transformers;
|
||||
|
||||
use FireflyIII\Models\Transaction;
|
||||
use League\Fractal\TransformerAbstract;
|
||||
use Symfony\Component\HttpFoundation\ParameterBag;
|
||||
|
||||
/**
|
||||
* Class TransactionTransformer
|
||||
*/
|
||||
class TransactionTransformer extends TransformerAbstract
|
||||
{
|
||||
/** @var ParameterBag */
|
||||
protected $parameters;
|
||||
|
||||
/**
|
||||
* BillTransformer constructor.
|
||||
*
|
||||
* @param ParameterBag $parameters
|
||||
*/
|
||||
public function __construct(ParameterBag $parameters)
|
||||
{
|
||||
$this->parameters = $parameters;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Transaction $transaction
|
||||
*
|
||||
|
@ -26,12 +26,26 @@ namespace FireflyIII\Transformers;
|
||||
|
||||
use FireflyIII\User;
|
||||
use League\Fractal\TransformerAbstract;
|
||||
use Symfony\Component\HttpFoundation\ParameterBag;
|
||||
|
||||
/**
|
||||
* Class UserTransformer
|
||||
*/
|
||||
class UserTransformer extends TransformerAbstract
|
||||
{
|
||||
/** @var ParameterBag */
|
||||
protected $parameters;
|
||||
|
||||
/**
|
||||
* BillTransformer constructor.
|
||||
*
|
||||
* @param ParameterBag $parameters
|
||||
*/
|
||||
public function __construct(ParameterBag $parameters)
|
||||
{
|
||||
$this->parameters = $parameters;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param User $user
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user