public function getAllFightersData() { $genders = array('male', 'female'); $age_categories = $this->age_categories; $belts = $this->belt_colours; $menWeights = Helper::getMenWeights(); $womenWeights = Helper::getWomenWeights(); //gender / age-group / belt / weight foreach ($genders as $gender) { foreach ($belts as $belt) { foreach ($age_categories as $age => $values) { if ($gender == 'male') { $weights = $menWeights; } else { $weights = $womenWeights; } foreach ($weights as $weight => $textual) { $data[$gender][$age][$belt][$weight] = $this->getFightersFor($gender, $age, $belt, $weight); } } } } $data['genders'] = $genders; $data['age_categories'] = $age_categories; $data['belts'] = $belts; $data['menWeights'] = $menWeights; $data['womenWeights'] = $womenWeights; return $data; }
public function showProfile(Request $request, $id = null) { $user = User::find($id != null ? $id : $request->user()->id); if ($user != null) { if ($user->city_id != 0) { $city = Cities::find($user->city_id); } else { $city = null; } if ($user->birth_date != "0000-00-00") { $user->age = Helper::ageCalculator($user->birth_date); } if ($user->ava != null) { $img = $user->ava; $user->ava = '/upload/' . $img; } if ($user->id == $request->user()->id) { $user->self = true; } else { $user->self = false; } return view()->make('user.show', array('user' => $user, 'city' => $city)); } else { return view()->make('error.access_denied'); } }
public function actionSignup() { $post = Application::request()->post(); $warning = ''; if (sizeof($post) > 0) { $model = new User(); $model->load($post); $validation = $model->validate(); if ($validation) { $user_id = $model->save(); if ($user_id) { Application::Identity()->signin($user_id); $this->redirect('/search'); } else { $warning = 'Error adding row to DB'; } } else { $warning = 'Please enter correct fields values'; } } if (!Application::Identity()->check()) { $this->render('signup.html', ['salt' => Helper::generateCode(15), 'warning' => $warning]); } else { $this->redirect('/search'); } }
static function linkFor($type, $parameters = null, $class_attrib = null) { static $oTopCatM, $oCatZeroM, $oPageM; if (is_null($oTopCatM)) { $oTopCatM = new \App\Model\Topcat(); $oCatZeroM = new \App\Model\Catzero(); $oPageM = new \App\Model\Page(); } if (!is_array($parameters)) { $parameters = array($parameters); } // add lookup for APP_Interface_Routable $info = \App\Helper::requestInfo(); $helper = new \App\Helper\View(); switch (strtolower($type)) { case "pages": $page = $oPageM->find($parameters["id"]); if (empty($page)) { throw new PPI_Exception("No Page Found for ID {$parameters['id']}"); } $catzero = $oCatZeroM->find($page["catzero_id"]); $topcat = $oTopCatM->find($page["topcat_id"]); $link = $helper->makePageIDLink($topcat["title"], $catzero["title"], $page["title"], $page["page_id"]); if (!isset($parameters["text"])) { $parameters["text"] = $page["title"]; } break; case "topcats": $topcat = $oTopCatM->find($parameters["id"]); if (empty($topcat)) { throw new PPI_Exception("No Topcat Found for ID {$parameters['id']}"); } $link = $helper->makeTopcatLink($topcat["title"], $topcat["id"]); if (!isset($parameters["text"])) { $parameters["text"] = $topcat["title"]; } break; case "catzero": $catzero = $oCatZeroM->find($parameters["id"]); if (empty($catzero)) { throw new PPI_Exception("No Catzero Found for ID {$parameters['id']}"); } $topcat = $oTopCatM->find($catzero["topcat_id"]); $link = $helper->makeCatzeroLink($topcat["title"], $catzero["title"], $catzero["id"]); if (!isset($parameters["text"])) { $parameters["text"] = $catzero["title"]; } break; case "search_terms": $link = "/search/index/{$parameters['title']}"; if (!isset($parameters["text"])) { $parameters["text"] = $parameters["title"]; } break; default: $link = "#err-no-handler:{$type}"; } return "<a href=\"{$link}\">{$parameters['text']}</a>"; }
public function handle($request, Closure $next) { if (Auth::check()) { $request->user()->id; view()->share('unread', Helper::checkUnreadMessages($request)); } view()->share('breadcrumb', 'home'); $url = $request->path(); view()->share('url', $url); return $next($request); }
/** * Action to redirect short link to normal link */ public function check() { $short = $this->router->getParam('short'); $modelLink = new Link(); $shortRow = $modelLink->getShort($short); if ($shortRow) { $modelLink->addClick($shortRow['id']); Helper::header(301, $shortRow['link']); exit; } Helper::header(404); }
public function uselessSwitch($param = false) { $exampleClass = new Example($param); switch ($exampleClass->getVal()) { case 'a': echo 'It was a'; break; default: echo Helper::missing($param); break; } }
public function getList(Request $request, $id = null) { if ($id != null) { $s = Seances::find($id); $c = Cinemas::find($s->cinema_id); $city_id = $c->city_id; } else { $city_id = $request->input('city_id'); } $users = new User(); if ($request->input('gender')) { $users = $users->where("gender", '=', $request->input('gender')); } if ($request->input('city_id') != 0) { $users = $users->where("city_id", '=', $city_id); } if ($request->input('age_from') != 0) { $users = $users->where(DB::raw("TIMESTAMPDIFF(YEAR,birth_date,CURDATE())"), '>=', $request->input('age_from')); } if ($request->input('age_to') != 0) { $users = $users->where(DB::raw("TIMESTAMPDIFF(YEAR,birth_date,CURDATE())"), '<=', $request->input('age_to')); } $users = $users->where("status", "enable"); $users = $users->where("id", '<>', $request->user()->id); $users = $users->get(); $cities = Cities::orderBy('city')->get(); $cityList = []; $cityList[0] = 'Любой'; foreach ($cities as $key => $value) { $cityList[$value->id] = $value->city; } foreach ($users as $key => $user) { if ($user->ava != 'noava.jpeg') { $img = $user->ava; $users[$key]->ava = '/upload/' . $img; } else { $users[$key]->ava = '/images/noava.jpeg'; } $age = Helper::ageCalculator($user->birth_date); $users[$key]->age = $age == null ? " " : $age; if ($user->city_id != '0') { $users[$key]->city = Cities::find($user->city_id)->city; } else { $users[$key]->city = " "; } } return view()->make('search.user_filter', array('users' => $users, 'cityList' => $cityList, 'city_id' => $city_id, 'age_from' => $request->input('age_from') ? $request->input('age_from') : 0, 'age_to' => $request->input('age_to') ? $request->input('age_to') : 0, 'gender' => $request->input('gender'), 'id' => $id)); }
public static function getPoster($link, $width = 200, $height = 0) { if (file_exists(base_path() . '/public/upload/' . $link)) { $img = Image::make(base_path() . '/public/upload/' . $link); } else { $original_name = $link; $link = \App\Helper::getPosterLink($link); $img = Image::make($link); $img->resize($width, null, function ($constraint) { $constraint->aspectRatio(); }); $img->save(base_path() . '/public/upload/' . $original_name); } $response = response()->make($img->encode('jpg')); $response->header('Content-Type', 'image/jpg'); return $response; }
private static function copyBootstrap() { $bootStrapFolder = self::BOOTSTRAP_FOLDER; $assetsFolder = self::getAssetsFolder(); if (!is_dir($bootStrapFolder)) { throw new \Exception('can not find bootstrap folder'); } if (!is_dir($assetsFolder)) { throw new \Exception('can not find assets folder'); } Helper::copy($bootStrapFolder, $assetsFolder); }
$customers_to_update = DB\Customer::where('postcode', $customer->postcode); // Make API request Log::msg('Making API request for postcode: "' . $customer->postcode . '"'); $geocode->makeRequest($customer->postcode); // Get the address from the call $customer_address = $geocode->getAddressInfo(); // Proceed only if the customer_address is true if ($customer_address) { // Update Lat/Long for all the customers where postcode = $customer->postcode Log::msg('Updating all customers latitude/longitude where postcode: ' . $customer->postcode); $customers_to_update->update(['latitude' => $customer_address['latitude'], 'longitude' => $customer_address['longitude']]); // Get the customer distance to all depots $distances = []; $sort_distance = []; foreach (DB\Depot::all() as $depot) { $d = Helper::getDistanceBetweenCordinates($customer_address['latitude'], $customer_address['longitude'], $depot->latitude, $depot->longitude); $distances[$depot->id] = ['depot_id' => $depot->id, 'depot' => $depot->depot, 'depot_postcode' => $depot->postcode, 'distance_meters' => $d]; // Create sort array for array_multisort $sort_distance[$depot->id] = $d; } // Sort the distances by shortest distance first array_multisort($sort_distance, SORT_ASC, $distances); // Update customer.depot and depot_distance if ($distances && isset($distances[0])) { Log::msg('Closest three depots to the customer are: ' . print_r(array_slice($distances, 0, 3), 1)); // Update depot and depot distance for all the customers with the postcode Log::msg('Updating customers depot to "' . $distances[0]['depot_id'] . '"'); $customers_to_update->update(['depot' => $distances[0]['depot_id'], 'depot_distance' => $distances[0]['distance_meters'], 'no_results' => 0]); } else { Log::msg('Invalid $distances array: ' . print_r($distances, 1)); }
/** * Create shortcode and check if it already exists. If exists, then create another * * @return string */ public function createShort() { do { $short = Helper::randomString(); $shortRow = $this->getShort($short); } while ($shortRow); return $short; }
private function getCookie() { $cookie_user_id = !empty($_COOKIE[self::USER_ID]) ? Helper::FilterInput($_COOKIE[self::USER_ID]) : NULL; $cookie_user_sess_code = !empty($_COOKIE[self::USER_SESS_CODE]) ? Helper::FilterInput($_COOKIE[self::USER_SESS_CODE]) : NULL; if ($cookie_user_id && $cookie_user_sess_code) { return [self::USER_ID => $cookie_user_id, self::USER_SESS_CODE => $cookie_user_sess_code]; } return false; }
public function getThumbMidiAttribute() { return Helper::getImageSrc('/pictures/article/midi/' . $this->image_src, '/images/blank-image.png'); }