Questions tagged [thephpleague-fractal]
27 questions
0
votes
1 answer
Laravel two-way data transformer
I've been looking for a Laravel transformer that will format the fields both ways. Meaning I transform it when I return it to the client and then transform it too before saving it again to the database.
I know I can do this already using Fractal's…

Jed
- 1,054
- 1
- 15
- 34
0
votes
0 answers
How to remove data from fractal library
I'm using laravel 8 and fractal library.
I want to remove data property result of fractal with DataArraySerializer:
use League\Fractal\Serializer\DataArraySerializer;
class TransformerSerializer extends DataArraySerializer
{
public function…

S.M_Emamian
- 17,005
- 37
- 135
- 254
0
votes
0 answers
Laravel 7 (with Fractal) not including relationship counts when using withCount method
I'm a relatively new PHP developer, so I might get some of this wrong.
PHP: 7.4
Laravel/Lumen: 7.0
Fractal: 0.13-dev (I think)
I have a model, Programs.

commadelimited
- 5,656
- 6
- 41
- 77
0
votes
1 answer
How to return array instead of collection using Fractal Transformers in Laravel
I am using Fractal Transformers in one of the Laravel based REST API project. I have a $defaultInclude and thus have a function in the Transformer class(ReleaseTransformer) to process the includes. It is as follows :
public function…

Happy Coder
- 4,255
- 13
- 75
- 152
0
votes
0 answers
Retrieve List of Roles related to User using spatie/laravel-fractal, Permissions works perfectly
I followed this topic on getting list of roles and permissions through user model using spatie/laravel-permission but none are engaging on my kind of concern.
Want to retrieve list of roles related to user using spatie/laravel-fractal through…

Timothy Kimemia
- 1
- 2
0
votes
0 answers
Include related table from pivot table in Fractal's Transformers
In my Laravel project, I have 4 tables:
location
location_product
product
status
location_product is the intermediate table between location and product and it has a foreign key status pointing to the product_status table.
I'm using Fractal's…

Verhelst
- 1,492
- 2
- 22
- 46
0
votes
1 answer
Type of included data is null with JsonApiSerializer in Fractal
This is what I get at the moment with Fractal's JsonApiSerializer of Fractal in Laravel:
{
"type": "projects",
"id": "18",
"attributes": {
"name": "pariatur",
"parent_id": 1
},
…
user10686911
0
votes
1 answer
Cannot access id on Eloquent model
I have an api endpoint that gives a web chat on my front end a list of online friends, however the user id is not included in my json, I would like to include the user_id in my json, but on my controller when I add the print_r like so...
public…

Cory Baumer
- 397
- 3
- 16
0
votes
1 answer
League Fractal including multiple nested relationships
How can I include multiple child relationships using ?include=?
Example:
/store/1?include=books.author:downloads
The result would produce:
[
id: 1,
name: 'Book Name',
author: {
data: {
id: 1,
name: 'Author…

Ryan
- 131
- 4
0
votes
1 answer
Using parseincludes in Laravel5 Fractal
Struggling using parseIncludes in https://github.com/thephpleague/fractal.
I have two tables, Property and Weeks. Each property has many weeks. Using Fractal I can return my property item with a collection of weeks. What I want to do is use…

Paul Wright
- 445
- 5
- 16
0
votes
1 answer
How to make availableIncludes work in thephpleague/fractal
I'm having trouble implementing Fractal includes. I am trying to include posts with a particular user.
All goes well when I add 'posts' to $defaultIncludes at the top of my UserItemTransformer. Posts are included as expected.
However, posts are NOT…

webmonger
- 41
- 5
0
votes
1 answer
Cursor based pagination and UUID
I am looking at implementing UUID'd in place of auto-increment id and was wondering if or how I might integrate cursor based pagination with UUID's.
With simple auto-increments I can simply add/subtract on the current ID to find my next/previous but…

Mark Kendall
- 129
- 2
- 10