mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
Align notes with object, not separate.
This commit is contained in:
parent
214c7a6f3e
commit
2c2814c998
@ -25,6 +25,7 @@ namespace FireflyIII\Transformers;
|
|||||||
|
|
||||||
|
|
||||||
use FireflyIII\Models\Attachment;
|
use FireflyIII\Models\Attachment;
|
||||||
|
use FireflyIII\Repositories\Attachment\AttachmentRepositoryInterface;
|
||||||
use League\Fractal\Resource\Collection as FractalCollection;
|
use League\Fractal\Resource\Collection as FractalCollection;
|
||||||
use League\Fractal\Resource\Item;
|
use League\Fractal\Resource\Item;
|
||||||
use League\Fractal\TransformerAbstract;
|
use League\Fractal\TransformerAbstract;
|
||||||
@ -40,17 +41,20 @@ class AttachmentTransformer extends TransformerAbstract
|
|||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
protected $availableIncludes = ['user', 'notes'];
|
protected $availableIncludes = ['user'];
|
||||||
/**
|
/**
|
||||||
* List of resources to automatically include
|
* List of resources to automatically include
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
protected $defaultIncludes = ['user', 'notes'];
|
protected $defaultIncludes = ['user'];
|
||||||
|
|
||||||
/** @var ParameterBag */
|
/** @var ParameterBag */
|
||||||
protected $parameters;
|
protected $parameters;
|
||||||
|
|
||||||
|
/** @var AttachmentRepositoryInterface */
|
||||||
|
private $repository;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* BillTransformer constructor.
|
* BillTransformer constructor.
|
||||||
*
|
*
|
||||||
@ -61,20 +65,7 @@ class AttachmentTransformer extends TransformerAbstract
|
|||||||
public function __construct(ParameterBag $parameters)
|
public function __construct(ParameterBag $parameters)
|
||||||
{
|
{
|
||||||
$this->parameters = $parameters;
|
$this->parameters = $parameters;
|
||||||
}
|
$this->repository = app(AttachmentRepositoryInterface::class);
|
||||||
|
|
||||||
/**
|
|
||||||
* Attach the notes.
|
|
||||||
*
|
|
||||||
* @codeCoverageIgnore
|
|
||||||
*
|
|
||||||
* @param Attachment $attachment
|
|
||||||
*
|
|
||||||
* @return FractalCollection
|
|
||||||
*/
|
|
||||||
public function includeNotes(Attachment $attachment): FractalCollection
|
|
||||||
{
|
|
||||||
return $this->collection($attachment->notes, new NoteTransformer($this->parameters), 'notes');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -100,6 +91,8 @@ class AttachmentTransformer extends TransformerAbstract
|
|||||||
*/
|
*/
|
||||||
public function transform(Attachment $attachment): array
|
public function transform(Attachment $attachment): array
|
||||||
{
|
{
|
||||||
|
$this->repository->setUser($attachment->user);
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'id' => (int)$attachment->id,
|
'id' => (int)$attachment->id,
|
||||||
'updated_at' => $attachment->updated_at->toAtomString(),
|
'updated_at' => $attachment->updated_at->toAtomString(),
|
||||||
@ -111,6 +104,7 @@ class AttachmentTransformer extends TransformerAbstract
|
|||||||
'upload_uri' => route('api.v1.attachments.upload', [$attachment->id]),
|
'upload_uri' => route('api.v1.attachments.upload', [$attachment->id]),
|
||||||
'title' => $attachment->title,
|
'title' => $attachment->title,
|
||||||
'mime' => $attachment->mime,
|
'mime' => $attachment->mime,
|
||||||
|
'notes' => $this->repository->getNoteText($attachment),
|
||||||
'size' => (int)$attachment->size,
|
'size' => (int)$attachment->size,
|
||||||
'links' => [
|
'links' => [
|
||||||
[
|
[
|
||||||
|
@ -44,17 +44,20 @@ class BillTransformer extends TransformerAbstract
|
|||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
protected $availableIncludes = ['attachments', 'transactions', 'user', 'notes', 'rules'];
|
protected $availableIncludes = ['attachments', 'transactions', 'user', 'rules'];
|
||||||
/**
|
/**
|
||||||
* List of resources to automatically include
|
* List of resources to automatically include
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
protected $defaultIncludes = ['notes', 'rules'];
|
protected $defaultIncludes = ['rules'];
|
||||||
|
|
||||||
/** @var ParameterBag */
|
/** @var ParameterBag */
|
||||||
protected $parameters;
|
protected $parameters;
|
||||||
|
|
||||||
|
/** @var BillRepositoryInterface */
|
||||||
|
private $repository;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* BillTransformer constructor.
|
* BillTransformer constructor.
|
||||||
*
|
*
|
||||||
@ -65,6 +68,7 @@ class BillTransformer extends TransformerAbstract
|
|||||||
public function __construct(ParameterBag $parameters)
|
public function __construct(ParameterBag $parameters)
|
||||||
{
|
{
|
||||||
$this->parameters = $parameters;
|
$this->parameters = $parameters;
|
||||||
|
$this->repository = app(BillRepositoryInterface::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -82,20 +86,6 @@ class BillTransformer extends TransformerAbstract
|
|||||||
return $this->collection($attachments, new AttachmentTransformer($this->parameters), 'attachments');
|
return $this->collection($attachments, new AttachmentTransformer($this->parameters), 'attachments');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Attach the notes.
|
|
||||||
*
|
|
||||||
* @codeCoverageIgnore
|
|
||||||
*
|
|
||||||
* @param Bill $bill
|
|
||||||
*
|
|
||||||
* @return FractalCollection
|
|
||||||
*/
|
|
||||||
public function includeNotes(Bill $bill): FractalCollection
|
|
||||||
{
|
|
||||||
return $this->collection($bill->notes, new NoteTransformer($this->parameters), 'notes');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Attach the rules.
|
* Attach the rules.
|
||||||
*
|
*
|
||||||
@ -107,11 +97,9 @@ class BillTransformer extends TransformerAbstract
|
|||||||
*/
|
*/
|
||||||
public function includeRules(Bill $bill): FractalCollection
|
public function includeRules(Bill $bill): FractalCollection
|
||||||
{
|
{
|
||||||
/** @var BillRepositoryInterface $repository */
|
$this->repository->setUser($bill->user);
|
||||||
$repository = app(BillRepositoryInterface::class);
|
|
||||||
$repository->setUser($bill->user);
|
|
||||||
// add info about rules:
|
// add info about rules:
|
||||||
$rules = $repository->getRulesForBill($bill);
|
$rules = $this->repository->getRulesForBill($bill);
|
||||||
|
|
||||||
return $this->collection($rules, new RuleTransformer($this->parameters), 'rules');
|
return $this->collection($rules, new RuleTransformer($this->parameters), 'rules');
|
||||||
}
|
}
|
||||||
@ -167,7 +155,8 @@ class BillTransformer extends TransformerAbstract
|
|||||||
{
|
{
|
||||||
$paidData = $this->paidData($bill);
|
$paidData = $this->paidData($bill);
|
||||||
$payDates = $this->payDates($bill);
|
$payDates = $this->payDates($bill);
|
||||||
$data = [
|
$this->repository->setUser($bill->user);
|
||||||
|
$data = [
|
||||||
'id' => (int)$bill->id,
|
'id' => (int)$bill->id,
|
||||||
'updated_at' => $bill->updated_at->toAtomString(),
|
'updated_at' => $bill->updated_at->toAtomString(),
|
||||||
'created_at' => $bill->created_at->toAtomString(),
|
'created_at' => $bill->created_at->toAtomString(),
|
||||||
@ -184,6 +173,7 @@ class BillTransformer extends TransformerAbstract
|
|||||||
'active' => $bill->active,
|
'active' => $bill->active,
|
||||||
'attachments_count' => $bill->attachments()->count(),
|
'attachments_count' => $bill->attachments()->count(),
|
||||||
'pay_dates' => $payDates,
|
'pay_dates' => $payDates,
|
||||||
|
'notes' => $this->repository->getNoteText($bill),
|
||||||
'paid_dates' => $paidData['paid_dates'],
|
'paid_dates' => $paidData['paid_dates'],
|
||||||
'next_expected_match' => $paidData['next_expected_match'],
|
'next_expected_match' => $paidData['next_expected_match'],
|
||||||
'links' => [
|
'links' => [
|
||||||
|
Loading…
Reference in New Issue
Block a user