diff --git a/src/Exporters/AbstractExporter.php b/src/Exporters/AbstractExporter.php index 4a159ff..10a2b54 100644 --- a/src/Exporters/AbstractExporter.php +++ b/src/Exporters/AbstractExporter.php @@ -15,11 +15,12 @@ protected function getKeys() { return User::blueprint() ->fields() - ->except(['id', 'groups', 'roles', 'password']) + ->except(['groups', 'roles']) ->all() ->keys() - ->merge(['id', 'last_login']) ->merge(User::getComputedCallbacks()->keys()) + ->merge(['id', 'last_login']) + ->reject('password') ->all(); } @@ -27,18 +28,17 @@ protected function getData() { return Member::query()->get() ->map(function ($user) { - $data = $user->data(); - $computedData = $user->computedData(); - - return collect($this->getKeys()) - ->flip() - ->map(function ($field, $key) use ($data, $computedData) { - return $data[$key] ?? $computedData[$key] ?? null; - }) + $data = $user->data() + ->merge($user->computedData()) ->merge([ 'id' => $user->id(), + 'email' => $user->email(), 'last_login' => $user->lastLogin(), - ]) + ]); + + return collect($this->getKeys()) + ->flip() + ->map(fn ($field, $key) => $data->get($key)) ->all(); }) ->all();