why this resource return only:
{
"data": [
{
"type": "user_stats",
"id": "107"
}
]
}
if i have the serializer
class UserStatSerializer extends AbstractSerializer
{
protected $type = 'user_stats';
protected function getDefaultAttributes($model): array
{
return [
'id' => $model->id,
'user_id' => $model->user_id,
'base_stat_id' => $model->base_stat_id,
'value' => $model->value,
'createdAt' => Carbon::parse($model->created_at)->toIso8601String(),
'updatedAt' => Carbon::parse($model->updated_at)->toIso8601String(),
];
}
public function setRequest(ServerRequestInterface $request)
{
$this->request = $request;
}
}
and the model
class UserStat extends AbstractModel
{
protected $table = 'user_stats';
public $timestamps = true;
protected $primaryKey = 'id';
protected $fillable = ['user_id', 'base_stat_id', 'value', 'created_at', 'updated_at'];
}
class ShowUserStatsController extends AbstractListController
{
public $serializer = UserStatSerializer::class;
protected function data(ServerRequestInterface $request, Document $document)
{
$actor = RequestUtil::getActor($request);
$userId = Arr::get($request->getQueryParams(), 'userId');
return UserStat::query()->where('user_id', $userId)->get();
}
}
@SychO can you point me in the right direction?
if i do the var_dump on the query: return UserStat::query()->where('user_id', $userId)->get();
i can see the complete result, but the endpoint return only the above payload