1
In Laravel, how could I transform the following result below to an XML structure?
$usuarios = Usuario::with('nivel')->where(['status' => 1])->get()->toArray();
// Resultado:
[
'usuarios' => [
0 => [
'id' => 1,
'nome' => 'Wallace',
'nivel_id' => 4,
'nivel' => [
'id' => 4,
'nome' => 'Produção'
]
],
1 => [
'id' => 2,
'nome' => 'Wayne',
'nivel_id' => 5,
'nivel' => [
'id' => 5,
'nome' => 'Recepção'
]
]
]
];
How could I use objects Model
and Collection
, to convert to XML?
Remark: THE Model
is returning by the call of first
, and Collection
, by the call of get
.
You can use package: https://github.com/SoapBox/laravel-formatter With it you can generate the returns for XML :)
– Renan Leme