private function savePsychosocialSupportToDB($request, $benefiterId) { if ($request['psychosocial_statuses'] != null) { $psychosocialStatuses = $request['psychosocial_statuses']; foreach ($psychosocialStatuses as $psychosocialStatus) { \DB::table('benefiters_psychosocial_support')->insert($this->getPsychosocialSupportArrayForDBInsert($psychosocialStatus, $benefiterId)); } } }
public function __construct() { $this->greekStringConversion = new GreekStringConversionHelper(); $this->genders = \DB::table('genders_lookup')->get(); $this->allCountryAbandonReasons = \DB::table('country_abandon_reasons_lookup')->get(); $this->countryList = \DB::table('countries_lookup')->get(); $this->marital_statuses = \DB::table('marital_status_lookup')->get(); $this->educations = \DB::table('education_lookup')->get(); $this->binaryYesNo = \DB::table('binary_lookup')->get(); $this->workTitles = \DB::table('work_title_list_lookup')->get(); return $this->genders; }
public function getReportDataForBenefitersWorkTitle() { try { $benefitersCountByWork = \DB::select(\DB::raw("select work_title_id, count(work_title_id) as counter from benefiters group by work_title_id order by counter desc limit 20")); $workTitles = \DB::table('work_title_list_lookup')->get(); } catch (\Exception $e) { Log::error("A problem occurred while trying to count the users based on their work title.\n" . $e); return null; } // get array of the form 'work_title' => 'counter' $result = $this->getBenefitersWorkTitleNameCountArray($benefitersCountByWork, $workTitles); Log::info("Returning results with users based on their work title."); // return the newly created array return $result; }
/** * Insert new Match * * @param array $data * @return Participant */ public function create_match(array $data) { $players = Player::select('player_id', 'first_name', 'last_name', \DB::raw('CONCAT(first_name, " ", last_name) as full_name'))->lists('player_id', 'full_name'); //check to see if players exist in Players table $err = ''; if (!array_key_exists($data['player1'], $players)) { $err .= ' Not in Players table: ' . $data['player1']; } if (!array_key_exists($data['player2'], $players)) { $err .= ' Not in Players table: ' . $data['player2']; } if ($err == '') { $player1_id = $players[$data['player1']]; $player2_id = $players[$data['player2']]; $match = \DB::table('matches')->where('tournament_id', '=', $data['tournament_id'])->where('player1_id', '=', $player1_id)->where('player2_id', '=', $player2_id)->first(); if (is_null($match)) { $match = Match::create(['player1_id' => $player1_id, 'player2_id' => $player2_id, 'winner_id' => $player1_id, 'tournament_id' => $data['tournament_id'], 'match_date' => $data['match_date'], 'match_type' => $data['match_type'], 'match_division' => $data['match_division']]); } } }
public function createRole(array $data) { $getid = \DB::table('users')->where('email', '=', $data['correo_electronico'])->where('user_login', '=', $data['nombre_usuario'])->where('num_identificacion', '=', $data['numero_identificacion'])->first(); return RolesUsers::create(['user_id' => $getid->id, 'role_id' => $data['rol_usuario']]); }
private function findLawyerActionsFromLegalSessionId($legalSessionId) { return \DB::table('legal_lawyer_action')->where('legal_session_id', '=', $legalSessionId)->get(); }
/** * Create contributor and connect to book. * @param [int] $book_id Id of book. * @param [type] $data [description] * @param [type] $avatar [description] * @return [type] [description] */ public function createContributorAndConnectBook($book_id, $data, $avatar) { $user = $this->model->create(['lastname' => $data['name'], 'blurb' => $data['blurb'], 'email' => $data['email'], 'twitter_id' => $data['twitter_id'], 'github' => $data['github'], 'avatar' => $avatar]); DB::table('book_author')->insert(['author_id' => $user->id, 'book_id' => $book_id, 'is_main' => 2, 'royalty' => 0, 'is_accepted' => 1, 'message' => '']); }
private function getAllReferrals() { return \DB::table('benefiter_referrals_lookup')->get(); }
private function getMedicationIdFromName($drug) { $tmp = \DB::table('medical_medication_lookup')->where('description', 'like', '%' . $drug . '%')->first(); if ($tmp != null) { Log::info("Returning the drug id. [=" . $tmp->id . "]"); return $tmp->id; } else { Log::error("Couldn't find the drug id."); return null; } }
private function findLegalStatusIdFromName($legal_status) { // if $__legalStatuses is empty, then fill it with normalized legal statuses from DB... if (empty($this->__legalStatuses)) { $allLegalStatuses = \DB::table('legal_status_lookup')->get(); foreach ($allLegalStatuses as $legalStatus) { $this->__legalStatuses[$legalStatus->id] = $this->greekStringConversion->grstrtoupper($legalStatus->description); } } // ...else use the existent array // normalize $legal_status $tmp = $this->greekStringConversion->grstrtoupper($legal_status); $id = array_search($tmp, $this->__legalStatuses); // if legal status was not found in $legalStatuses array // return null if (!$id) { $id = null; } return $id; }
private function getWorkTitleIdFromDBAndInsertNewWorkTitleIfNeeded($workTitleFromForm) { // initialize the GreekStringConversionHelper service $greekStringConversion = new GreekStringConversionHelper(); $workTitleId = null; $allWorkTitlesAvailable = \DB::table('work_title_list_lookup')->get(); $workTitleFromForm = $greekStringConversion->grstrtoupper($workTitleFromForm); // if there are some work titles in DB if ($allWorkTitlesAvailable != null) { // check for each one if the names are the same after greek string conversion to uppercase foreach ($allWorkTitlesAvailable as $work_title) { $work_title->work_title = $greekStringConversion->grstrtoupper($work_title->work_title); // if strings are the same set the $workTitleId to the DB's id if (strcasecmp($work_title->work_title, $workTitleFromForm) == 0) { $workTitleId = $work_title->id; break; } } } // if work title was not found in DB if ($workTitleId == null) { $workTitleId = \DB::table('work_title_list_lookup')->insertGetId(array('work_title' => $workTitleFromForm)); } return $workTitleId; }