File: D:/HostingSpaces/SBogers95/rentman.io/app/Komma/ProductGroups/ProductGroupController.php
<?php
namespace App\Komma\ProductGroups;
use App\Http\Controllers\Controller;
use App\Komma\ProductGroups\Models\ProductGroup;
class ProductGroupController extends Controller
{
/**
* Create export of the translatable variable of all the product groups
*
* @return \Illuminate\Http\JsonResponse
*/
public function oneSkyExport()
{
\App::changeLanguageByIso2('en');
$productGroups = ProductGroup::with('translations', 'translation')
->get();
$exportJson = [];
foreach ($productGroups as $productGroup) {
// Generate the page JSON
$pricingJson = $this->oneSkyExporterService->generateModelJson($productGroup, ['name']);
if (count($pricingJson) == 0) {
continue;
}
// Generate the components JSON
$exportJson['product_group_'.$productGroup->id] = $pricingJson;
}
return response()->json($exportJson);
}
}