<commit_before><?php namespace App\Http\Controllers;

use App\Http\Requests;
use App\Http\Controllers\Controller;

use Illuminate\Http\Request;
use Validator;

use Input;
use Form;

class AcquedottoController extends Controller {

	/**
	 * Display a listing of the resource.
	 *
	 * @return Response
	 */
	public function index()
	{
		
		return array(
				1 => "Jon",
				2 => "May",
				3 => "Seven"
		);
		
	}

	/**
	 * Show the form for creating a new resource.
	 *
	 * @return Response
	 */
	public function create()
	{
		//
	}
	
	
	/**
	 * Store a newly created resource in storage.
	 *
	 * @return Response
	 */
	public function store()
	{
		
		$rules = array(
		'data_lettura'      	 => 'required|date',
		'consumo'	   			 => 'required|numeric',
		'idtacqua_dichiarazione' => 'required|numeric',
		'note' 					 => 'max:500'
		);
		
		
		$validator = Validator::make(\Input::all(), $rules);
		
		if ($validator->fails()) {
			
			
			return "<script>window.location='/portale/#/panel/errore/';</script>";
		}
		
		$url_photo="";
		if(\Input::file('photo_file'))
        {
  
			$image = \Input::file('photo_file');
            $filename  = time() . '.' . $image->getClientOriginalExtension();
            $path = public_path('uploaded_pictures/' . $filename);
			
        
           
			if(\File::copy($image , $path))
			{
			
				$url_photo="/api/public/uploaded_pictures/".$filename;
			}
			else
			{
				return "<script>window.location='/portale/#/panel/errore/';</script>";
			}
           
        }
		
		
		$data = date('Y-m-d', strtotime(\Input::get('data_lettura')));
		$lettura = \Input::get('lettura');
		$consumo = \Input::get('consumo');
		$idacqua = \Input::get('idtacqua_dichiarazione');
		$note = \Input::get('note');
		
		//$data=str_replace('-', '/', $data);
		$inserimento=\DB::table('tacqua_dichiarazione_lettura')->insert([
				[ 'idtacqua_dichiarazione'=> $idacqua,'data_lettura'=>$data,'lettura' => ((float)$lettura),'consumo' => ((float)$consumo),'fatturata' => 2,'note' => $note,'idtacqua_tbl_tipo_lettura' =>4,'url_foto'=>$url_photo]
			]);
		<commit_msg>Fixed inserimento lettura upload file<commit_after><?php namespace App\Http\Controllers;

use App\Http\Requests;
use App\Http\Controllers\Controller;

use Illuminate\Http\Request;
use Validator;

use Input;
use Form;

class AcquedottoController extends Controller {

	/**
	 * Display a listing of the resource.
	 *
	 * @return Response
	 */
	public function index()
	{
		
		return array(
				1 => "Jon",
				2 => "May",
				3 => "Seven"
		);
		
	}

	/**
	 * Show the form for creating a new resource.
	 *
	 * @return Response
	 */
	public function create()
	{
		//
	}
	
	
	/**
	 * Store a newly created resource in storage.
	 *
	 * @return Response
	 */
	public function store()
	{
		
		$rules = array(
		'data_lettura'      	 => 'required|date',
		'consumo'	   			 => 'required|numeric',
		'idtacqua_dichiarazione' => 'required|numeric',
		'note' 					 => 'max:500',
		'photo_file'			 => 'image|max:2048'
		);
		
		
		$validator = Validator::make(\Input::all(), $rules);
		
		if ($validator->fails()) {
			
			
			return "<script>window.location='/portale/#/panel/errore/';</script>";
		}
		
		$url_photo="";
		if(\Input::file('photo_file'))
        {
			$file_allegato = \Input::file('photo_file');
			$filename  = time() . '.' . $file_allegato->getClientOriginalExtension();
			$path = public_path('uploaded_pictures/');
			if($file_allegato->move($path, $filename))
			{
				$url_photo="/api/public/uploaded_pictures/".$filename;
			}
			else
			{
				return "<script>window.location='/portale/#/panel/errore/';</script>";
			}
        }

		$data = date('Y-m-d', strtotime(\Input::get('data_lettura')));
		$lettura = \Input::get('lettura');
		$consumo = \Input::get('consumo');
		$idacqua = \Input::get('idtacqua_dichiarazione');
		$note = \Input::get('note');
		
		//$data=str_replace('-', '/', $data);
		$inserimento=\DB::table('tacqua_dichiarazione_lettura')->insert([
				[ 'idtacqua_dichiarazione'=> $idacqua,'data_lettura'=>$data,'lettura' => ((float)$lettura),'consumo' => ((float)$consumo),'fatturata' => 2,'note' => $note,'idtacqua_tbl_tipo_lettura' =>4,'url_foto'=>$url_photo]
			]);
		
{'fraction_non_alphanumeric': 0.19312485079971353, 'fraction_numerical': 0.004774409166865601, 'mean_word_length': 3.2323232323232323, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 49, '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': '5993886', 'n_tokens_mistral': 1738, 'n_tokens_neox': 1482, 'n_words': 239}