public function sync()
 {
     $timecard_data = Input::get('timecard_data');
     $inventory_data = Input::get('inventory_data');
     $positions_modified = Input::get('positions_modified');
     $users_modified = Input::get('users_modified');
     $timecard_modified = Input::get('timecard_modified');
     $checklists_modified = Input::get('checklists_modified');
     $inventory_modified = Input::get('inventory_modified');
     foreach ($inventory_data as $entry) {
         $record = \App\Inventory::findOrFail($entry["guid"]);
         $record->quantity_on_hand = $entry["quantity_on_hand"];
         $record->updated_at = Carbon::createFromTimestamp($entry["last_modified"], 'America/Chicago');
         $record->save();
         $adj = new \App\InventoryAdjustment();
         $adj->inventory_id = $record->id;
         $adj->quantity_on_hand = $record->quantity_on_hand;
         $adj->save();
     }
     $stamp = "";
     foreach ($timecard_data as $entry) {
         $stamp = date_default_timezone_get();
         $record = \App\Timecard::where('guid', $entry["guid"])->first();
         if ($record) {
             $record->guid = $entry["guid"];
             $record->clock_in = Carbon::createFromTimestamp($entry["clock_in"], 'America/Chicago');
             if ($entry["clock_out"] == '0') {
                 $record->clock_out = null;
             } else {
                 $record->clock_out = Carbon::createFromTimestamp($entry["clock_out"], 'America/Chicago');
             }
             $record->save();
         } else {
             $record = new \App\Timecard();
             $record->guid = $entry["guid"];
             $record->clock_in = Carbon::createFromTimestamp($entry["clock_in"], 'America/Chicago');
             if ($entry["clock_out"] == '0') {
                 $record->clock_out = null;
             } else {
                 $record->clock_out = Carbon::createFromTimestamp($entry["clock_out"], 'America/Chicago');
             }
             $record->user_id = $entry["user_id"];
             $record->position_id = $entry["position_id"];
             $record->save();
         }
     }
     $users_last_modified = Carbon::createFromTimestamp($users_modified)->toDateTimeString();
     $users = \App\User::where('updated_at', '>', $users_last_modified)->get();
     $timecard_last_modified = Carbon::createFromTimestamp($timecard_modified)->toDateTimeString();
     $timecards = \App\Timecard::where('updated_at', '>', $timecard_last_modified)->get();
     $positions_last_modified = Carbon::createFromTimestamp($positions_modified)->toDateTimeString();
     $positions = \App\Position::withTrashed()->where('updated_at', '>', $positions_last_modified)->get();
     $checklists_last_modified = Carbon::createFromTimestamp($checklists_modified)->toDateTimeString();
     $checklist = \App\Checklist::withTrashed()->where('updated_at', '>', $checklists_last_modified)->get();
     $inventory_last_modified = Carbon::createFromTimestamp($inventory_modified)->toDateTimeString();
     $inventory = \App\Inventory::withTrashed()->where('updated_at', '>', $inventory_last_modified)->get();
     return Response::json(["users" => $users, "checklist" => $checklist, "inventory" => $inventory, "timecards" => $timecards, "positions" => $positions]);
 }
 /**
  * Update the specified resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function update($id)
 {
     $timecard = \App\Timecard::find($id);
     $timecard->clock_in = Carbon::createFromTimeStamp(Input::get('clock_in'), 'America/Chicago');
     $timecard->clock_out = Carbon::createFromTimeStamp(Input::get('clock_out'), 'America/Chicago');
     $timecard->save();
 }