Closed Esperancia closed 5 years ago
provide sample code and expected vs actual data you get, so we can understand the issue here
`<?php
namespace App;
use Sofa\Eloquence\Eloquence; class User extends Authenticatable { use Eloquence; ... } `
Now try to get all users:
$users = User::all();
This returns: [{"id":18,"name":"xxx","email":"xx@xx.xx","created_at":"2018-11-19 09:09:20","updated_at":"2018-11-19 09:09:20","enabled":"Y","phone":null,"profile_picture":null,"pivot":{"role_id":6,"model_id":18}}]
What I expected (because I need to use Collection methods: flatten, filter, map, where, push...) ` ( [guard_name:protected] => web [guarded:protected] => Array ( )
[connection:protected] => pgsql
[table:protected] =>
[primaryKey:protected] => id
[keyType:protected] => int
[incrementing] => 1
[with:protected] => Array
(
)
[withCount:protected] => Array
(
)
[perPage:protected] => 15
[exists] => 1
[wasRecentlyCreated] =>
[attributes:protected] => Array
(
[id] => 5
[name] => Géraldo AGOHOUE
[email] => gagohoue@mcabenin2.bj
[organisation] => MCA-Bénin II
[title] => Assistant Web
[created_at] => 2018-11-09 20:22:32
[updated_at] => 2018-11-09 20:22:32
[enabled] => Y
[phone] => ,
...
)
[original:protected] => Array
(
[id] => 18
[name] => xxxx
[email] => xxx@xxx.bj
[created_at] => 2018-11-09 20:22:32
[updated_at] => 2018-11-09 20:22:32
[enabled] => Y
[phone] =>
... => ....
)
...
) `
Just an example. Getting this format would save me from rewriting existing functions that worked well.
Sofa returns something like [{"id":18,"name":"xxx","email":"xx@xx.xx","created_at":"2018-11-19 09:09:20","updated_at":"2018-11-19 09:09:20","enabled":"Y","phone":null,"profile_picture":null,"pivot":{"role_id":6,"model_id":18}}] This requires reviewing all existing requests and processing because they fail. Any solution to format into default collection format?