<commit_before><?php
class DeviceController extends \BaseController {

	/**
	 * Връща JSON със данните от API-то
	 *
	 * @return Response
	 */
	public function index()
	{	
		$Settings = Settings::orderBy('created_at','desc')->first();
		if(count($Settings) == 0){
			return Response::json("Няма намерени ресурси, моля отидете на менюто: Настройки");
		}else{
			return Response::json(json_decode(file_get_contents($Settings['api'])));
		}
	}

	

}<commit_msg>Add new Method to procces new data and save it to database<commit_after><?php
class DeviceController extends \BaseController {

	/**
	 * Връща JSON със данните от API-то
	 *
	 * @return Response
	 */
	public function index()
	{	
		$Settings = Settings::orderBy('created_at','desc')->first();
		if(count($Settings) == 0){
			return Response::json("Няма намерени ресурси, моля отидете на менюто: Настройки");
		}else{
				$result = json_decode(file_get_contents($Settings['api']));
		
				$this->processNewData($result);
				return Response::json($result);
		}
	}

	public function processNewData($result){
				for ($i=0; $i < count($result->devices); $i++) { 
					if (Device::where('name','=',$result->devices[$i]->name)->count()) {
						$deviceTemp = Device::where('name','=',$result->devices[$i]->name)->first();
						$newValue = new Value(array('value' => $result->devices[$i]->value));
						$save = $deviceTemp->values()->save($newValue);
					}
				}
	}

	

}
{'fraction_non_alphanumeric': 0.1844319775596073, 'fraction_numerical': 0.0021037868162692847, 'mean_word_length': 4.324626865671642, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 18, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3087304', 'n_tokens_mistral': 545, 'n_tokens_neox': 486, 'n_words': 96}