public function addContributor() { $contributor_first_name = Input::get('contributor-first-name'); $contributor_last_name = Input::get('contributor-last-name'); $contributor_mobile = Input::get('contributor-mobile'); $contributor_obj = NULL; if (Auth::guest()) { $contributor_obj = User::createContributorAndSave($contributor_first_name, $contributor_last_name, $contributor_mobile); Auth::login($contributor_obj, true); } else { // A user is logged in already. The contributor name and mobile can be same or different // ONLY checking by mobile right now. TODO : check if this is OK if ($contributor_mobile != Auth::user()->mobile) { Log::info("mobile num not equal. MAKE NEW CONTRIB USER !!"); // Using same contributor twice. Or uses existing user as contributor without knowing that they exist on this platform $contributor_obj = User::createContributorIfNotExists($contributor_first_name, $contributor_last_name, $contributor_mobile); } else { Log::info("mobile num equal. Auth is Contributor !! "); $contributor_obj = Auth::user(); $contributor_obj->makeContributor(); } } $au_file = Input::file('au-file'); $upload_number = Auth::user()->incrementUploadNumber(); $new_file_name = $contributor_first_name . $contributor_mobile . '_uploaded_by_' . Auth::user()->fname . $upload_number . '.csv'; $new_file_location = app_path() . '/database/seedAfterReview/'; $au_file->move($new_file_location, $new_file_name); // I will review. No automatic upload //$file_full_path = $new_file_location . $new_file_name; //Helper::createArmyUpdatesFromFileForContributor($file_full_path, $contributor_obj->id); return Redirect::to('dashboard'); }
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); }