0
I’m using the fractal
next to the Laravel
to manipulate my collections
. In some Transformers I use the available include
(as an example below).
What I’d like to do is include a goal with array
of those includes
.
Example:
meta:{includes: {include1: badah, include2: badah},data{dados...}
Code:
<?php
namespace apiAneel\Transformers;
use apiAneel\Entities\AccountPlan;
use League\Fractal\TransformerAbstract;
/**
* Class AccountPlanTransformer
* @package namespace apiAneel\Transformers;
*/
class AccountPlanTransformer extends TransformerAbstract
{
public $availableIncludes = ['acrCod', 'companyType'];
/**
* Transform the \AccountPlan entity
* @param \AccountPlan $model
*
* @return array
*/
public function transform(AccountPlan $model)
{
return [
'id' => $model->id,
'cod' => $model->cod,
'description' => $model->description,
'dep_cod' => $model->dep_cod,
'dep_description' => $model->dep_description,
'expense_cod' => $model->expense_cod,
'expense_description' => $model->expense_description
];
}
public function includeAcrCod(AccountPlan $accountPlan)
{
$acrCod = $accountPlan->acrCod;
return $this->item($acrCod, new AcrCodTransformer());
}
public function includeCompanyType(AccountPlan $accountPlan)
{
$companyType = $accountPlan->companyType;
return $this->item($companyType, new CompanyTypeTransformer());
}
}
Is this factral a package? what does it do? Where is it to be used?
– novic
Fractal is a PHP library, to process data. Link to details
– Allan Santos
does not have that option in the package, should perhaps ask for some innovation in its github, open a Issue, because in the current package I did not see this option.
– novic
vdd has, but my doubt is how to use this functionality next to Transformer
– Allan Santos
So please edit your question and show where it is... I didn’t find.
– novic
I found this inside the link pagination I took a look at the class
Cursor
but, it doesn’t have what you need. There’s no implementation for adding settings, at least that’s what I saw in the class.– novic