i am new here, i have a problem with an api in laravel. I want to show all the records from two tables. Table a : Flights; Table b: Details_flights;
class FilterController extends Controller
{
public function product(Request $request) {
$flights= Flight::all();
$details = Flights_detail::all();
if(empty($flights)) {
return response()->json([
'success' => true,
'length' => 0,
'error' => 'No fly found',
'results' => []
]);
}else {
return response()->json([
'success' => true,
'length' => $flights->count(),
'results' => $flights
]);
}
}
}
I tried with array_merge(table A, table B) but it didn't work.
Someone can help me?