/** * Generate unique reference * * @return string */ public function uniqueReference() { do { $reference = Str::upper(Str::random($this->referenceLength())); } while (self::where($this->referenceField(), '=', $reference)->count() > 0); return $reference; }
/** * Validates the Turkish Identity Number over HTTP connection to goverment sys * @param array ['tcno' => string, 'isim' => string, 'soyisim' => string, 'dogumyili' => int] * @return bool */ public static function validate($data = []) { if (!static::verify($data)) { return false; } if (count(array_diff(static::$validationfields, array_keys($data))) != 0) { return false; } foreach (static::$validationfields as $field) { $data[$field] = Str::upper($data[$field]); } $post_data = '<?xml version="1.0" encoding="utf-8"?> <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> <soap:Body> <TCKimlikNoDogrula xmlns="http://tckimlik.nvi.gov.tr/WS"> <TCKimlikNo>' . $data['tcno'] . '</TCKimlikNo> <Ad>' . $data['isim'] . '</Ad> <Soyad>' . $data['soyisim'] . '</Soyad> <DogumYili>' . $data['dogumyili'] . '</DogumYili> </TCKimlikNoDogrula> </soap:Body> </soap:Envelope>'; $ch = curl_init(); // CURL options $options = array(CURLOPT_URL => 'https://tckimlik.nvi.gov.tr/Service/KPSPublic.asmx', CURLOPT_POST => true, CURLOPT_POSTFIELDS => $post_data, CURLOPT_RETURNTRANSFER => true, CURLOPT_SSL_VERIFYPEER => false, CURLOPT_HEADER => false, CURLOPT_HTTPHEADER => array('POST /Service/KPSPublic.asmx HTTP/1.1', 'Host: tckimlik.nvi.gov.tr', 'Content-Type: text/xml; charset=utf-8', 'Content-Length: ' . strlen($post_data), 'SOAPAction: "http://tckimlik.nvi.gov.tr/WS/TCKimlikNoDogrula"')); curl_setopt_array($ch, $options); $response = curl_exec($ch); curl_close($ch); return strip_tags($response) === 'true' ? true : false; }
public function update(Request $request, $id) { $departamento = $request->input('departamento'); if ($departamento != '0') { try { DB::beginTransaction(); $usuario = User::find($id); $empleado = $usuario->empleado; $empleado->nombre = Str::upper($request->input('nombre')); $empleado->apellido_paterno = Str::upper($request->input('apellido_paterno')); $empleado->apellido_materno = Str::upper($request->input('apellido_materno')); $empleado->save(); $usuario->username = Str::upper($request->input('username')); $usuario->password = bcrypt($request->input('password')); $usuario->rol_id = $request->input('departamento'); $usuario->save(); DB::commit(); return redirect()->route('usuario.index'); } catch (QueryException $e) { echo $e; DB::rollBack(); return redirect()->route('usuario.edit', $id); } } else { return redirect()->route('usuario.edit', $id); } }
public function run() { DB::table('facings')->truncate(); $faker = Faker::create(); foreach (range(1, 20) as $index) { Facing::create(['name' => Str::upper($faker->randomLetter), 'angle' => '5-25', 'is_obstructed' => $faker->boolean(50), 'contact_time' => '5-25', 'illumination_type' => '5-25', 'distance_from_road' => '5-25', 'billboard_proximity' => '50-100', 'billboard_id' => Billboard::find($faker->numberBetween(1, 20))->id]); } }
public function autocomplete() { $term = Str::upper(Input::get('term')); $data = Cie::where('description', 'LIKE', '%' . $term . '%')->get(); foreach ($data as $v) { $return_array[] = array('value' => $v->code, 'label' => $v->description); } return Response::json($return_array); }
/** * Update the specified resource in storage. * * @param \Illuminate\Http\Request $request * @param int $id * @return \Illuminate\Http\Response */ public function update(Request $request, $id) { $empleado = Empleado::find($id); $empleado->nombre = Str::upper($request->input('nombre')); $empleado->apellido_paterno = Str::upper($request->input('apellido_paterno')); $empleado->apellido_materno = Str::upper($request->input('apellido_materno')); $empleado->save(); return redirect()->route('surtidores'); }
public function autocomplete() { $term = Str::upper(Input::get('term')); $data = Colonia::where('colonia', 'LIKE', '%' . $term . '%')->get(); foreach ($data as $v) { $return_array[] = array('value' => $v->id, 'label' => $v->zipcode . ' - ' . $v->colonia); } return Response::json($return_array); }
protected function doReplacements($message, $attribute, $rule, $parameters) { $value = $attribute; $message = str_replace([':ATTRIBUTE', ':Attribute', ':attribute'], [Str::upper($value), Str::ucfirst($value), $value], $message); if (isset($this->replacers[Str::snake($rule)])) { $message = $this->callReplacer($message, $attribute, Str::snake($rule), $parameters); } elseif (method_exists($this, $replacer = "replace{$rule}")) { $message = $this->{$replacer}($message, $attribute, $rule, $parameters); } return $message; }
/** * Find a handler for manage a request * * @param string $method * @param string $path * @return null|callable */ public function find($method, $path) { $method = Str::upper($method); $handlers = $this->handlers[$method]; if (Arr::exists($handlers, $path)) { return $handlers[$path]; } foreach ($handlers as $regexPath => $handler) { if (preg_match('@^' . $regexPath . '$@', $path)) { return $handler; } } }
public static function __callStatic($name, $attributes) { if (Str::startsWith('get', $name)) { $method = Str::camel($name); if (method_exists(new static(), $method)) { $class = static::class; if (Arr::exists($attributes, 0)) { return $class::$method($attributes[0]); } return $class::$method(); } } return env(Str::upper(Str::snake(Str::substr($name, 3)))); }
public function create(Input $input) { $promotions = $input->get('promotion'); if ($promotions != []) { foreach ($promotions as $n => $promotion) { $dpt = new Promotion(); $dpt->firstOrCreate(['nom' => Str::upper($promotion)]); } Session::flash('flash_success', 'Vos promotions ont bien été créées'); } else { Session::flash('flash_error', 'Aucun champs n\'a été envoyé'); } $promotions = $this->promotion->all(); return redirect(route('admin_promotion_get', compact('promotions'))); }
/** * Set attributes to upper case automatically */ public function selfUpperCase() { if (is_array($this->attributes)) { foreach ($this->attributes as $field => $value) { if (is_string($value)) { if (property_exists($this, 'guardedCase')) { if (!in_array($field, $this->guardedCase)) { $this->{$field} = Str::upper($value); } } else { $this->{$field} = Str::upper($value); } } } } }
/** * Loads a locale. * * @param string $country The domain * @param string $locale A locale * * @throws NotFoundResourceException when the resource cannot be found * @throws InvalidResourceException when the resource cannot be loaded * * @return array */ public function load(string $country, string $locale) : array { $country = Str::upper($country); $filename = "{$this->path}/{$locale}/{$country}.php"; try { $loaded = $this->files->getRequire($filename); if (!is_array($loaded)) { throw new InvalidResourceException(); } return $loaded; } catch (FileNotFoundException $e) { throw new NotFoundResourceException("{$filename} not found.", 0, $e); } catch (\Throwable $e) { throw new InvalidResourceException("{$filename} has invalid resources.", 0, $e); } }
/** * Store a newly created resource in storage. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ public function store(Request $request) { try { $unidad = $request->input('unidad'); $placas = $request->input('placas'); $marca = $request->input('marca'); $modelo = $request->input('modelo'); $anio = $request->input('anio'); $cap_tanque = $request->input('cap_tanque'); $rendimiento = $request->input('rendimiento'); $peso = $request->input('peso'); $serie = $request->input('serie'); $propiedad = $request->input('propiedad'); $observaciones = $request->input('observaciones'); if ($propiedad != "0") { $vehiculo = new Vehiculo(); $vehiculo->unidad = Str::upper($unidad); $vehiculo->placas = Str::upper($placas); $vehiculo->marca = Str::upper($marca); $vehiculo->modelo = Str::upper($modelo); $vehiculo->anio = $anio; $vehiculo->cap_tanque = $cap_tanque; $vehiculo->rendimiento = $rendimiento; $vehiculo->peso = $peso; $vehiculo->serie = Str::upper($serie); $vehiculo->propiedad = Str::upper($propiedad); $vehiculo->observaciones = Str::upper($observaciones); $vehiculo->save(); return redirect()->route('vehiculos'); } else { return redirect()->route('nuevovehiculo'); } } catch (Exception $ex) { echo $ex; } }
public function getConstantName($humanReadableName) { return 'XML_' . Str::upper(Str::snake($humanReadableName)) . '_NODE'; }
/** * Check if value is an Oracle reserved word. * * @param string $value * @return bool */ public function isReserved($value) { return in_array(Str::upper(trim($value)), $this->reserves, true); }
/** * Get column name to be use for filtering and sorting. * * @param integer $index * @param bool $wantsAlias * @return string */ protected function getColumnName($index, $wantsAlias = false) { $column = $this->request->columnName($index); // DataTables is using make(false) if (is_numeric($column)) { $column = $this->getColumnNameByIndex($index); } if (Str::contains(Str::upper($column), ' AS ')) { $column = $this->extractColumnName($column, $wantsAlias); } return $column; }
public function addNewEditor($request) { $data = array(); $rules = ['name' => 'required|min:3|alpha']; $messages = ['name.required' => 'Το όνομα είναι υποχρεωτικό', 'name.min' => 'Το όνομα του εκδότη πρέπει να είναι τουλάχιστον 3 χαρακτήρες', 'name.alpha' => 'Το όνομα του εκδότη πρέπει να είναι Αγγλικοί ή Ελληνικοί χαρακτήρες']; if ($request->ajax()) { $validator = \Validator::make($request->all(), $rules, $messages); if ($validator->fails()) { return \Response::json($validator->errors()->all(), 422); } else { $editor = Editor::create(['e_name' => Str::upper($request->get('name'))]); if ($editor) { $data['sweetalert'] = ['title' => 'Συγχαρητήρια', 'body' => 'ο εκδότης προστέθηκε με επιτυχία', 'level' => 'success']; $data['editor']['name'] = $editor->e_name; $data['editor']['id'] = $editor->id; } else { $data['sweetalert'] = ['title' => 'Πρόβλημα', 'body' => 'ο εκδότης ΔΕΝ αποθηκεύτηκε...', 'level' => 'error']; } return \Response::json($data); } } }
/** * Formatar float para o número de casas decimais correto. * @param $nome * @param $valor * @return string */ protected function formatar($nome, $valor) { $ref = new \ReflectionProperty(get_class($this), $nome); $factory = DocBlockFactory::createInstance(); $info = $factory->create($ref->getDocComment()); // Pegar o tipo da variavel $tipo = $info->getTagsByName('var'); $tipo = count($tipo) == 0 ? 'string' : $tipo[0]->getType(); $tipo = strtolower($tipo); switch ($tipo) { case 'string': case 'string|null': case '\\string': case '\\string|null': $valor = str_replace(['@'], ['#1#'], utf8_encode($valor)); // Ignorar alguns caracteres no ascii $valor = Str::ascii($valor); $valor = str_replace(['&'], ['e'], $valor); $valor = str_replace(['#1#'], ['@'], $valor); // Retornar caracteres ignorados $valor = Str::upper($valor); $valor = trim($valor); // Max $max = $info->getTagsByName('max'); if (count($max) > 0) { $max = intval($max[0]->getDescription()->render()); $valor = trim(substr($valor, 0, $max)); } return $valor; case 'float|null': case 'float': $dec = $info->getTagsByName('dec'); if (count($dec) == 0) { return $valor; } // Valor do @dec $dec = $dec[0]->getDescription()->render(); return number_format($valor, $dec, '.', ''); case 'datetime': case '\\datetime': case '\\datetime|null': case 'date': case 'date|null': case '\\date': case '\\date|null': if (is_int($valor)) { $valor = Carbon::createFromTimestamp($valor); } if (is_string($valor)) { return $valor; } $format = in_array($tipo, ['date', 'date|null', '\\date', '\\date|null']) ? 'Y-m-d' : Carbon::ATOM; return $valor->format($format); default: return $valor; } }
/** * Gets the function that is passed to the Twig environment. * * @return \Closure */ public function getFilter() { return function ($string) { return Str::upper($string); }; }
/** * Setup column name to be use for filtering. * * @param integer $i * @param bool $wantsAlias * @return string */ public function setupColumnName($i, $wantsAlias = false) { $column = $this->getColumnName($i); if (Str::contains(Str::upper($column), ' AS ')) { $column = $this->extractColumnName($column, $wantsAlias); } return $column; }
/** * Setup column name to be use for filtering. * * @param integer $i * @return string */ public function setupColumnName($i) { $column = $this->getColumnName($i); if (Str::contains(Str::upper($column), ' AS ')) { $column = $this->extractColumnName($column); } return $column; }
/** * Setup column name to be use for filtering. * * @param array $columns * @param int $i * @return string */ private function setupColumn(array $columns, $i) { $column = $this->getColumnIdentity($columns, $i); if (Str::contains(Str::upper($column), ' AS ')) { $column = $this->getColumnName($column); } // there's no need to put the prefix unless the column name is prefixed with the table name. $column = $this->prefixColumn($column); return $column; }
protected function setGuarNameAttribute($value) { $this->attributes['guar_name'] = Str::upper($value); }
/** * @param string $key * * @return array */ protected function parseKey(string $key) { return preg_split('/[ .]/', Str::upper($key)); }
/** * @param $string * @param array $arguments * @return mixed * @author Rytis Grincevičius <*****@*****.**> */ public static function applyArguments($string, array $arguments = array()) { foreach ($arguments as $key => $value) { $string = str_replace([':' . Str::upper($key), ':' . Str::ucfirst($key), ':' . $key], [Str::upper($value), Str::ucfirst($value), $value], $string); } return $string; }
/** * Make the place-holder replacements on a line. * * @param string $line * @param array $replace * @return string */ protected function makeReplacements($line, array $replace) { $replace = $this->sortReplacements($replace); foreach ($replace as $key => $value) { $line = str_replace([':' . Str::upper($key), ':' . Str::ucfirst($key), ':' . $key], [Str::upper($value), Str::ucfirst($value), $value], $line); } return $line; }
/** * Setup column name to be use for filtering. * * @param integer $i * @return string */ public function setupColumnName($i) { $column = $this->getColumnName($i); if (Str::contains(Str::upper($column), ' AS ')) { $column = $this->extractColumnName($column); } // there's no need to put the prefix unless the column name is prefixed with the table name. $column = $this->prefixColumn($column); return $column; }
/** * Check if value is an Oracle reserved word. * * @param string $value * @return bool */ public function isReserved($value) { return \DB::connection()->getDriverName() == 'oracle' && in_array(Str::upper(trim($value)), $this->reserves, true); }
function applyReplacement($line, $replacements) { foreach ($replacements as $key => $value) { $line = str_replace([':' . Str::upper($key), ':' . Str::ucfirst($key), ':' . $key], [Str::upper($value), Str::ucfirst($value), $value], $line); } return $line; }