I have this methode: Route::get('/export', function () { return response()->json([ 'Devices' => Device::all(), 'purchasingInformations' => PurchasingInformation::all(), 'OwnerTransactions' => OwnerTransaction::all(), 'LocationTransactions' => LocationTransaction::all() ]); }); but i want to use the id of for example the devices as key for my json To use the id of the Device model as a key in your JSON response, you can modify your code to map each device to an array with the device id as the key. Here's an example: php Route::get('/export', function () { $devices = Device::all()->mapWithKeys(function ($device) { return [$device->id => $device]; }); return response()->json([ 'Devices' => $devices, 'purchasingInformations' => PurchasingInformation::all(), 'OwnerTransactions' => OwnerTransaction::all(), 'LocationTransactions' => LocationTransaction::all() ]); }); In this modified code, we first retrieve all Device models using the all() method. We then call the mapWithKeys method on the resulting collection to transform it into an associative array where the device id is the key and the device model is the value. We then pass this modified $devices variable to the JSON response, so that the devices will be outputted with their ids as keys. The other collections are passed as is without modification. Note that if you have multiple models with the same id, the later models will overwrite the earlier ones in the JSON response. ------------- can i also do it without an key, just the objects? Yes, you can also return an array of objects without using keys. Here's an example: scss Route::get('/export', function () { return response()->json([ 'Devices' => Device::all()->toArray(), 'purchasingInformations' => PurchasingInformation::all()->toArray(), 'OwnerTransactions' => OwnerTransaction::all()->toArray(), 'LocationTransactions' => LocationTransaction::all()->toArray() ]); }); In this code, we're using the toArray() method to convert each collection of models to an array of objects. These arrays are then included in the JSON response with their corresponding names as keys. This will return an array of objects without keys. However, keep in mind that if you have multiple models with the same primary key value, their data will be merged into a single object in the JSON response, which may not be what you intended.