/** * Store a newly created resource in storage. * * @param Request $request * @return Response */ public function store(Request $request) { $token = $request->t; $sensortype = $request->s; $card_no = $request->c; $status = 0; // check if valid terminal $terminal = Terminal::where('token', $token)->where('active', 1)->first(); if (!empty($terminal)) { $employee = Employee::where('card_no', $card_no)->where('active', 1)->first(); if (!empty($employee)) { $timelog = new EmployeeTime(); $timelog->employee_id = $employee->id; $timelog->terminal_id = $terminal->id; $timelog->timestamp = Carbon::now(); $timelog->sensortype_id = $sensortype; $timelog->save(); $status = 1; } } return response()->json(['status' => $status], 200); }
/** * Process datatables ajax request. * * @return \Illuminate\Http\JsonResponse */ public function anydata() { // $records = EmployeeTime::getLastTen(); // dd($records); return Datatables::of(EmployeeTime::getLastTen())->make(true); }