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' // ) ); // } $found_name = Input::get('found-name'); $found_age = Input::get('found-age'); $found_father_name = Input::get('found-father-name'); Log::info("===========================in FoundPeopleController create [start]"); Log::info($found_name); // If not logged in, it could be New User or Returning User if (Auth::guest()) { $finder_first_name = Input::get('finder-first-name'); $finder_last_name = Input::get('finder-last-name'); $finder_mobile = Input::get('finder-mobile'); $returning_user = User::where('mobile', '=', $finder_mobile)->get()->first(); if ($returning_user) { Auth::login($returning_user, true); } else { // New user $finder_obj = User::createFinderAndSave($finder_first_name, $finder_last_name, $finder_mobile); // Manually logging in user and 'Remember me' = true. // So no need to use Auth::attempt Auth::login($finder_obj, true); } } if (Auth::guest()) { dd('why is there no Authenticated User here'); } if (!Auth::user()->finder) { Auth::user()->makeFinder(); } Auth::user()->setAffiliation(Input::get('found-by')); // TODO: check for duplicates before creating another record $fop = FoundPeople::createNewForFinder($found_name, $found_age, $found_father_name, Auth::user()->id); Log::info("========[in FouldPeopleController -> fop is]=========="); Log::info($fop); $fip_search_results = FindPeople::searchWithNameAndAge($found_name, $found_age); Log::info("============[got back fip_search_results]=============="); Log::info($fip_search_results); foreach ($fip_search_results as $fip_result) { Log::info($fip_result); FindPeople::find($fip_result['id'])->createNewMatch(FoundPeople::TABLE_NAME, $fop); } Log::info("============[created matches]=============="); // TODO : maybe add AU also // TODO : create Message on Auth::user (Finder) saying Thank you for posting Found Record ? $response = array('status' => 'success', 'username' => Auth::user()->fname, 'fname' => Helper::getDisplayFirstNameFrom($found_name), 'lname' => Helper::getDisplayLastNameFrom($found_name), 'age' => $found_age, 'msgCount' => Auth::user()->messages()->count(), 'msg' => 'Person inserted in Found-People Table successfully'); Log::info("===========================in FoundPeopleController create [end]"); 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); }
$find_people_list = FindPeople::orderBy('created_at', 'dsc')->get(); return View::make('find_person/list', ['find_people_list' => $find_people_list]); })); Route::get('found/report', array('as' => 'found.person.report', 'uses' => function () { $found_people_list = FoundPeople::orderBy('created_at', 'dsc')->get(); return View::make('found_person/list', ['found_people_list' => $found_people_list]); })); Route::post('/find', array('as' => 'find.people.create', 'uses' => 'FindPeopleController@create')); Route::post('deletefip', array('as' => 'find.person.delete', 'uses' => 'FindPeopleController@delete'))->before('auth'); Route::get('findperson/edit/{id}', array('as' => 'find.person.edit', 'uses' => function ($id) { $fip = FindPeople::find($id); return View::make('find_person/edit', ['fip' => $fip]); }))->before('auth'); Route::post('findperson/edit/{id}', array('as' => 'find.person.edit', 'uses' => 'FindPeopleController@edit'))->before('auth'); Route::get('findperson/show/{id}', array('as' => 'find.person.show', 'uses' => function ($id) { $fip = FindPeople::find($id); $looker = $fip->getLooker(); return View::make('find_person/show', ['fip' => $fip, 'looker' => $looker]); })); Route::post('/found', array('as' => 'found.people.create', 'uses' => 'FoundPeopleController@create')); 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');
public function edit() { $fip_id = Input::get('fip-id'); Log::info("===========================in FindPeopleController EDIT [fip_id] is =>"); Log::info($fip_id); $fip = FindPeople::find($fip_id); // Storing the image $image_file = Input::file('fip-photo-file'); if ($image_file) { $image_file_name = 'FIP_id_' . $fip_id . '.' . $image_file->guessClientExtension(); $image_file_location = 'images/FIP_photos/'; $image_file->move($image_file_location, $image_file_name); if ($fip->photo_url) { // delete old upload unlink(app_path() . '/../public' . $fip->photo_url); } $fip->photo_url = '/' . $image_file_location . $image_file_name; } $fip->description = Input::get('fip-desc'); $fip->save(); return Redirect::route('find.person.show', $fip_id); }
private static function getBuilderWithParam($find_name, $find_age) { Log::info("*********************[FindPeople::getBuilderWithParam]*********************"); Log::info("********[find_name]************"); Log::info($find_name); Log::info("********[find_age]************"); Log::info($find_age); $name = false; $age = false; if ($find_name) { $name = true; } if ($find_age) { $age = true; } $results = array(); $explanation = ""; if ($name && !$age) { // Only Name Specified // First-name and Last-name search // $results = DB::table('FoundPeople') // ->where('first-name', '=', $updates_name) // ->orWhere('last-name', '=', $updates_name) // ->get(); // Substr match // $results = FindPeople::whereRaw('first_name LIKE ? and last_name LIKE ?', array( // '%'.$find_first_name.'%', '%'.$find_last_name.'%' // )); $results = Helper::searchTableForName(FindPeople::TABLE_NAME, $find_name); // TODO : separate out exact matches and substr matches and disp them separately } elseif ($age && !$name) { // Only Age Specified $results = FindPeople::where('age', '=', $find_age); } elseif ($name && $age) { // Name, Age Specified // $results = FindPeople::whereRaw('( first_name LIKE ? and last_name LIKE ? ) and age = ?', array( // '%'.$find_first_name.'%', '%'.$find_last_name.'%', $find_age // )); $results = Helper::searchTableForNameAndAge(FindPeople::TABLE_NAME, $find_name, $find_age); // TODO : separate out exact matches and substr matches and disp them separately } return $results; }