<?php

namespace App\Http\Controllers;

use App\User;
use Request;
use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\DB;

class DataController extends Controller
{
    /**
     * Show the profile for the given user.
     *
     * @param  int  $computer_id
     */
    public function get($id=null)
    {
        $where = [];
        $computer_id = Request::input('computer_id');
        $from = Request::input('from');
        $to = Request::input('to');
        $where[] = ["computer_id", '=', $computer_id];
        if ($from) $where[] = ["created_at", '>=', $from];
        if ($to) $where[] = ["created_at", '<=', $to];
        $queries = DB::table('values')->where($where)->get();
        return response()->json($queries);
    }
}