<?php
unlink(PATH.'/view/tool/'.$Route->params->self.'/data.json');
$client 	= new \GuzzleHttp\Client(); 
$response 	= $client->request('GET', 'https://games.gamepix.com/categories', ['verify' => false]);
$Data 		= json_decode($response->getBody(),true);

$Listings = [];
foreach($Data['data'] as $Key) {
	$Listings['category'][] = [
		'name'		=> $Key['name'],
		'url'		=> $Key['id']
	];  
}   
$Listings['sort'][] = [
	'name'		=> 'Newest',
	'url'		=> 'd'
];  
$Listings['sort'][] = [
	'name'		=> 'Most Played',
	'url'		=> 'q'
]; 

$JsonData = json_encode($Listings,JSON_UNESCAPED_UNICODE);

$fp = fopen(PATH.'/view/tool/'.$Route->params->self.'/data.json', 'w+');
fwrite($fp, $JsonData);
fclose($fp);