function load($id) { $candidate = null; if (Cache::has($id)) { $candidate = Cache::get($id); } else { //load the candidate data from Bullhorn $candidate = new \Stratum\Model\Candidate(); $candidate->set("id", $id); $bc = new BullhornController(); $bc->load($candidate); Cache::add($id, $candidate, 60); } return $candidate; }
private function loadCorporateUser() { $user = Auth::user(); $id = $user->bullhorn_id; Log::debug("User has ID " . $id); $cuser = null; if (!$id) { //load by name $name = $user->name; Log::debug("User has name " . $name); $bc = new BullhornController(); $cuser = $bc->findCorporateUserByName($name); $theId = $cuser->get("id"); if ($theId) { $user->bullhorn_id = $theId; $user->save(); } } else { //we have a bullhorn id $cuser = null; if (Cache::has("user" . $id)) { Log::debug("Loading corporate user from cache: " . $id); $cuser = Cache::get("user" . $id); } else { //load the corporate user data from Bullhorn $cuser = new \Stratum\Model\CorporateUser(); $cuser->set("id", $id); $bc = new BullhornController(); $cuser = $bc->loadCorporateUser($cuser); } } return $cuser; }