public function getSourceClaimer() { if ($this->match_army_update) { return ArmyUpdates::find($this->match_table_id)->getClaimer(); } if ($this->match_found_person) { return FoundPeople::find($this->match_table_id)->getClaimer(); } }
public function getFoundTablePostURL() { if ($this->found) { if ($this->found_in_army_updates) { return ArmyUpdates::find($this->found_table_id)->fb_url; } elseif ($this->found_in_found_people) { return "foundperson/show/" . $this->found_table_id; } else { return NULL; } // this should never happen (by design) } return NULL; // this should never happen (by assumption) }
public function search() { //check if its our form (prevents cross site injections) // TODO #7 // if ( Session::token() !== Input::get( '_token' ) ) { // return Response::json( array( // 'msg' => 'Unauthorized attempt to create option' // ) ); // } Log::info(Input::all()); $updates_sno = Input::get('updates-sno'); $updates_name = Input::get('updates-name'); $updates_age = Input::get('updates-age'); Log::info("===[AU Search]==="); Log::info($updates_sno); Log::info($updates_name); Log::info($updates_age); $results = ArmyUpdates::searchWithParam($updates_sno, $updates_name, $updates_age); Log::info("===[AU Search Results]==="); Log::info(json_encode($results)); $response = array('status' => 'success', 'results' => json_encode($results)); return Response::json($response); }
private function doClaim($is_duplicate) { $claim_match_id = Input::get('match-id'); Log::info("======[claim_match_id]======"); Log::info($claim_match_id); Log::info(Input::all()); $match = Match::find($claim_match_id); $fip = FindPeople::find($match->fip_id); // MARK match as claimed and FIP as found $match->claimed = true; $match->save(); $fip->found = true; $fip->duplicate = $is_duplicate; if ($match->match_army_update) { $fip->found_in_army_updates = true; $au = ArmyUpdates::find($match->match_table_id); $au->claimed = true; $au->save(); // not deleting. allowing duplicate claims instead //Match::where('match_table_id', '=', $au->id)->delete(); } if ($match->match_found_person) { $fip->found_in_found_people = true; $fop = FoundPeople::find($match->match_table_id); $fop->claimed = true; $fop->save(); //Match::where('match_table_id', '=', $fop->id)->delete(); } $fip->found_table_id = $match->match_table_id; $fip->save(); Match::deleteMatchesForFip($fip->id); // TODO : also send back the id in the table it was matched to // Turn into Found $response = array('status' => 'success', 'fip-id' => $fip->id); return Response::json($response); }
Route::get('foundperson/show/{id}', array('as' => 'found.person.show', 'uses' => function ($id) { $fop = FoundPeople::find($id); $finder = $fop->getFinder(); return View::make('found_person/show', ['fop' => $fop, 'finder' => $finder]); })); Route::get('foundperson/edit/{id}', array('as' => 'found.person.edit', 'uses' => function ($id) { $fop = FoundPeople::find($id); return View::make('found_person/edit', ['fop' => $fop]); }))->before('auth'); Route::post('foundperson/edit/{id}', array('as' => 'found.person.edit', 'uses' => 'FoundPeopleController@edit'))->before('auth'); Route::post('deletefop', array('as' => 'found.people.delete', 'uses' => 'FoundPeopleController@delete'))->before('auth'); Route::get('AUdata', array('as' => 'au.data', 'uses' => function () { return Response::json(ArmyUpdates::all(array('first_name', 'age'))); })); Route::get('/updates', array('as' => 'updates', 'uses' => function () { $army_updates_pag = ArmyUpdates::orderBy('s_no', 'asc')->paginate(ArmyUpdates::SHOW_PER_PAGE); return View::make('armyupdates', ['army_updates_pag' => $army_updates_pag]); })); Route::post('/updates', array('as' => 'army.updates.search', 'uses' => 'ArmyUpdatesController@search')); Route::get('/contributors', array('as' => 'contributors', 'uses' => function () { $cu_list = User::where('contributor', true)->get()->sortByDesc('contributed'); return View::make('contributors', ['contributor_users_list' => $cu_list]); })); Route::get('/contributor/add/form', array('as' => 'contributor.add.form', 'uses' => function () { return View::make('contributor/add'); })); Route::post('/contributor/add', array('as' => 'contributor.add', 'uses' => 'ArmyUpdatesController@addContributor')); Route::get('/donate', array('as' => 'donate', 'uses' => function () { $dc_list = DonationCause::all(); return View::make('donate/list', ['donation_causes_list' => $dc_list]); }));
public function create() { //check if its our form // TODO #7 // if ( Session::token() !== Input::get( '_token' ) ) { // return Response::json( array( // 'msg' => 'Unauthorized attempt to create option' // ) ); // } $find_name = Input::get('find-name'); $find_age = Input::get('find-age'); Log::info("===========================in FindPeopleController create [start]"); Log::info($find_name); Log::info($find_age); // find_age is str // If not logged in, it could be New User or Returning User if (Auth::guest()) { /////// Create User of type Looker $looker_first_name = Input::get('looker-first-name'); $looker_last_name = Input::get('looker-last-name'); $looker_mobile = Input::get('looker-mobile'); $returning_user = User::where('mobile', '=', $looker_mobile)->get()->first(); if ($returning_user) { Auth::login($returning_user, true); } else { // New user $looker_obj = User::createLookerAndSave($looker_first_name, $looker_last_name, $looker_mobile); // Manually logging in user and 'Remember me' = true. // So no need to use Auth::attempt Auth::login($looker_obj, true); } } if (!Auth::user()->looker) { Auth::user()->makeLooker(); } // TODO: check for duplicates before creating another record $fip = FindPeople::createNewForLooker($find_name, $find_age, Auth::user()->id); // If we wanted to print the findPeople per user. // $fp = User::find($looker_id)->findPeople()->get(); // Log::info($fp); // Now that 'Looker' has created a new 'Fip', we should try to match this Fip against AU and FOP // TODO This code might need to move somewhere else // Doing only AU for now. TODO do FOP $au_search_results = ArmyUpdates::searchWithNameAndAge($find_name, $find_age); Log::info("==[AU search results]=="); Log::info($au_search_results); // If the number of search_results > 0, i.e. matches found, create matches on FIP. (Alerts to FIP->Looker fired automatically) // FIP->hasMany(Matches) if (count($au_search_results)) { $fip->createNewMatches(ArmyUpdates::TABLE_NAME, $au_search_results); } $fop_search_results = FoundPeople::searchWithNameAndAge($find_name, $find_age); if (count($fop_search_results)) { $fip->createNewMatches(FoundPeople::TABLE_NAME, $fop_search_results); } Log::info("========[in FindPeopleController -> fop__search_result is]=========="); Log::info($fop_search_results); $num_matches = count($au_search_results) + count($fop_search_results); $response = array('status' => 'success', 'username' => Auth::user()->fname, 'notificationCount' => $num_matches, 'fname' => Helper::getDisplayFirstNameFrom($find_name), 'lname' => Helper::getDisplayLastNameFrom($find_name), 'age' => $find_age, 'msgCount' => Auth::user()->messages()->count(), 'msg' => 'Person inserted in Find-People Table successfully'); Log::info("===========================in FindPeopleController create [end]"); return Response::json($response); }
private static function createFromCSVFormat2($listing) { $contributor_fname = $listing[0]; $contributor_lname = $listing[1]; $contributor_mob = $listing[2]; $s_no = $listing[3]; $first_name = $listing[4]; $last_name = $listing[5]; $age = $listing[7]; $fb_url = $listing[10]; $w_child = $listing[11]; $contributor = User::createContributorIfNotExists($contributor_fname, $contributor_lname, $contributor_mob); // TODO: add col address and w-child and additional $update = ArmyUpdates::createNewForContributor($s_no, $first_name, $last_name, $age, $fb_url, $contributor->id); }
private static function getBuilderWithParam($find_sno, $find_name, $find_age) { $sno = false; $name = false; $age = false; if ($find_name) { $name = true; } if ($find_age) { $age = true; } if ($find_sno) { $sno = true; } $results = ArmyUpdates::where('s_no', '=', 0); // This returns an empty Builder obj // TODO : figure out better way $explanation = ""; if ($sno) { // This can only return one row (I think . TODO: check assumption) $results = ArmyUpdates::where('s_no', '=', $find_sno); $explanation = "Do not search on 'S.no.' and Another field together. 'S.no.' is unique for every update, so it will never match 2 records. This search is returning results for 'S.no.' = " . $find_sno . "."; } elseif ($name && !$age) { // Only Name Specified $results = Helper::searchTableForName(ArmyUpdates::TABLE_NAME, $find_name); // TODO : separate out exact matches and substr matches and disp them separately } elseif ($age && !$name) { // Only Age Specified $results = ArmyUpdates::where('age', '=', $find_age); } elseif ($name && $age) { // Name, Age Specified $results = Helper::searchTableForNameAndAge(ArmyUpdates::TABLE_NAME, $find_name, $find_age); // TODO : separate out exact matches and substr matches and disp them separately } return $results; }