/** * Record a generic activity entry for the user * * @param integer $userId * @param integer $keyFobId * @param string $deviceKey * @param Carbon $time * @return Activity */ public function recordMemberActivity($userId, $keyFobId, $deviceKey, Carbon $time = null) { if (empty($time)) { $time = Carbon::now(); } $activity = $this->model->create(['user_id' => $userId, 'key_fob_id' => $keyFobId, 'service' => $deviceKey, 'response' => 200, 'created_at' => $time]); if ($activity) { event(new MemberActivityRecorded($activity)); } return $activity; }
public function status() { $keyId = \Input::get('data'); try { $keyFob = $this->lookupKeyFob($keyId); } catch (\Exception $e) { return \Response::make(json_encode(['valid' => '0']), 200); } $user = $keyFob->user()->first(); $log = new Activity(); $log->key_fob_id = $keyFob->id; $log->user_id = $user->id; $log->service = 'status'; $log->save(); $statusString = $user->status; return \Response::make(json_encode(['valid' => '1', 'name' => $user->name, 'status' => $statusString]), 200); }