Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

League Fractal dependency issue after update #41

Open
AbhijeetSomwanshi opened this issue Aug 23, 2017 · 3 comments
Open

League Fractal dependency issue after update #41

AbhijeetSomwanshi opened this issue Aug 23, 2017 · 3 comments

Comments

@AbhijeetSomwanshi
Copy link

Getting an error after upgrading:

Type error: Argument 1 passed to League\Fractal\Scope::filterFieldsets() must be of the type array, integer given, called in /vendor/league/fractal/src/Scope.php on line 385

@AbhijeetSomwanshi AbhijeetSomwanshi changed the title Issue after update League Fractal dependency issue after update Aug 23, 2017
@Cyvelnet
Copy link
Owner

@AbhijeetSomwanshi there is an opened issue in thephpleague/fractal#374, but may i get a repro/sample code ? maybe i can get around it in this package scope

@AbhijeetSomwanshi
Copy link
Author

AbhijeetSomwanshi commented Aug 23, 2017

This is my Controller code where I am getting this error,

$family_details = FamilyMember::where('user_id', '=', $family_id)->get(); $member_details = Fractal::collection($family_details, new FamilySurveyTransformer)->getArray();

And my transformer code,

public function transform(FamilyMember $member) { return [ 'id' => $member->id, 'family_id' => $member->user_id, 'member_name' => $member->m_name, 'member_age' => $member->m_age, 'member_gender' => $member->m_gender, ]; }

@Cyvelnet
Copy link
Owner

@AbhijeetSomwanshi i cant repro that error with your code sample, but i guess you have something similar to this in your transfomer class

public function includeXYZ($resource){
    // return something which is not an array
    return $resource->id;
}

the alternative is to use league/fractal 0.17.0 feature primitive() at the moment.

public function includeXYZ($resource){
    return $this->primitive($resource->id);
}

i will tag a new release soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants