I have 2 tables, being CustomerCpf
and CustomerCnpj
.
They have no connection to each other.
What would be the best way to pass the 2 tables on the same route with a json?
I had thought of something like this:
public function getAll(){
$pessoaFisica = CustomerCpf::all();
$pessoaJuridicaa = CustomerCnpj::all();
$data = [
"data" => [
"fisica" => $pessoaFisica,
"juridica" => $pessoaJuridicaa
]
];
return response()->json([$data]);
}