本文整理汇总了PHP中Illuminate\Support\Str类的典型用法代码示例。如果您正苦于以下问题:PHP Str类的具体用法?PHP Str怎么用?PHP Str使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Str类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: doRegister
public function doRegister(Request $request)
{
$validator = Validator::make($data = $request->all(), Admin::$rules, Admin::$messages);
if ($validator->fails()) {
return Redirect::back()->withErrors($validator)->withInput();
}
if ($validator->passes()) {
$confirmation_code = Str::quickRandom(30);
$admin = new Admin();
$admin->fullname = ucwords($request->fullname);
$admin->mobile_no = $request->mobile_no;
$admin->email = $request->email;
$admin->password = bcrypt($request->password);
$admin->confirmation_code = $confirmation_code;
$data = ['confirmation_code' => $confirmation_code, 'username' => $request->username, 'password' => $request->password, 'mobile_no' => $request->mobile_no];
Basehelper::sendSMS($request->mobile_no, 'Hello ' . $request->username . ', you have successfully registere. Your username is ' . $request->username . ' and password is ' . $request->password);
// Mail::send('emails.verify', $data, function($message) use ($admin, $data){
// $message->from('no-reply@employment_bank', 'Employment Bank');
// $message->to(Input::get('email'), $admin->name)
// ->subject('Verify your email address');
// });
if (!$admin->save()) {
return Redirect::back()->with('message', 'Error while creating your account!<br> Please contact Technical Support');
}
return Redirect::route('admin.login')->with('message', 'Account has been created!<br>Now Check your email address to verify your account by checking your spam folder or inboxes for verification link after that you can login');
//sendConfirmation() Will go the email and sms as needed
} else {
return Redirect::back()->withInput()->withErrors($validation);
// ->with('message', 'There were validation errors.');
}
}
示例2: search
/**
* Search for physicians.
*
* @return JSON
*/
public function search(Request $request)
{
$physicians = null;
$searchDistance = $request->distance ? $request->distance : 0;
$coords = $this->getCoordinates($request);
$orderBy = $request->has('order_by') ? $request->order_by : 'distance';
$sort = $request->has('sort') ? $request->sort : 'asc';
$limit = $request->has('per_page') ? $request->per_page : '25';
// if we don't have a requested distance, we'll cycle through
// our fallback distances until we get at least 1 result;
// if we don't have anything by our max distance, we'll return 0.
if (!$request->has('distance')) {
while (!$physicians || $physicians->count() == 0) {
$searchDistance = $this->getNextDistance($searchDistance);
$physicians = Physician::withinDistance($coords['lat'], $coords['lon'], $searchDistance)->alias($request->alias_id)->name($request->q)->gender($request->gender);
if ($searchDistance == $this->maxDistance) {
break;
}
}
} else {
$physicians = Physician::withinDistance($coords['lat'], $coords['lon'], $searchDistance)->alias($request->alias_id)->name($request->q)->gender($request->gender);
}
$alias = Alias::find($request->alias_id);
$queryMeta = ['city' => Str::title(urldecode($request->city)), 'state' => mb_strtoupper($request->state), 'zip' => $request->zip ? $request->zip : $this->getZip($request->city, $request->state), 'alias' => $alias ? $alias->alias : null, 'alias_id' => $alias ? $alias->id : null, 'aggregate' => AggregateReporter::report($physicians, $request->alias_id), 'q' => $request->q, 'gender' => $request->gender, 'count' => $physicians ? $physicians->count() : 0, 'radius' => $searchDistance, 'order_by' => $request->order_by, 'sort' => $request->sort, 'center' => ['lat' => $coords['lat'], 'lon' => $coords['lon']]];
$physicians = $physicians->orderBy($orderBy, $sort)->paginate($limit)->appends($request->query());
return $this->response->withPaginator($physicians, new PhysicianTransformer(), null, $queryMeta);
}
示例3: boot
/**
* Overrides the models boot method.
*/
public static function boot()
{
parent::boot();
self::creating(function ($tag) {
$tag->slug = Str::slug($tag->name);
});
}
示例4: run
public function run()
{
DB::table('projects')->delete();
Project::create(['name' => 'Deployer', 'hash' => Str::random(60), 'repository' => 'https://github.com/REBELinBLUE/deployer.git', 'url' => 'http://deploy.app', 'group_id' => 2, 'private_key' => '-----BEGIN RSA PRIVATE KEY-----
MIIEowIBAAKCAQEAmrMjtajVvmd99T8xwUNrIFbrzSmZ6VCM89hfm4Ut9atv29gG
l2HFPJY7VtslXDJVL67w5EUMspy82tkAX7F03iaarSsbo6nC16UTfbfNTi44Snm0
T/5RMavSOnOMRJ8BQcfzqge4oIQzVGXOs0YvNFdSt4paBp9dssKS+7yP/hDvgAVz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a0nj29LPIx7kofsRWTz3d
vKmsy7swRhkdN6P/lR/29mnKg1EwnmKP1RjkZfyyKznHl+SaSVoVL/dQAw2TwPS6
AL+6SlU9yw+vrxihc1g8uKICL5M+1hnoWj50EEvyZJoRXuHsR72UbEd1w454/ZHX
TvjxDQKBgCtikMNAqTParY/tX0xNohD7+svTKZt92CxW7Q/17H26ehFKUQvw6Agd
ulR2AVTGi6STEgzXf6UP5CAVhYRw9irCAQYpceL0GVzfZPQsXyLuMCnJ8UD6CBRn
i5vkNY4OZdOuEV9boFOFYa58WRNK7vthHkZJj++Amu3dZ6RHBlLQ
-----END RSA PRIVATE KEY-----', 'public_key' => 'ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCasyO1qNW+Z331PzHBQ2sgVuvNKZnpUIzz2F+bhS31q2/b2Aa' . 'XYcU8ljtW2yVcMlUvrvDkRQyynLza2QBfsXTeJpqtKxujqcLXpRN9t81OLjhKebRP/lExq9I6c4xEnwFBx/OqB7' . 'ighDNUZc6zRi80V1K3iloGn12ywpL7vI/+EO+ABXP4sTchwh47bppcBNy4HjOre+NqpLNZkZ02E4lngSaOCY6r3' . '6TdICaigeQX6n/Xgwm2rRkr0qNIZsd/IoyLYS6/CWUUJjX16qxXt1wwMiwwpRbZ2IULnZ0lI74QXjucD+Ow0OKw' . 'WwgLsN55VUGXVOlpX1GJ2p5mZ3H6YX0B deploy@deployer', 'last_run' => null, 'build_url' => 'http://ci.rebelinblue.com/build-status/image/3?branch=master']);
}
示例5: data
/**
* {@inheritdoc}
*/
public function data(ServerRequestInterface $request, Document $document)
{
$this->assertAdmin($request->getAttribute('actor'));
$file = array_get($request->getUploadedFiles(), 'favicon');
$tmpFile = tempnam($this->app->storagePath() . '/tmp', 'favicon');
$file->moveTo($tmpFile);
$extension = pathinfo($file->getClientFilename(), PATHINFO_EXTENSION);
if ($extension !== 'ico') {
$manager = new ImageManager();
$encodedImage = $manager->make($tmpFile)->resize(64, 64, function ($constraint) {
$constraint->aspectRatio();
$constraint->upsize();
})->encode('png');
file_put_contents($tmpFile, $encodedImage);
$extension = 'png';
}
$mount = new MountManager(['source' => new Filesystem(new Local(pathinfo($tmpFile, PATHINFO_DIRNAME))), 'target' => new Filesystem(new Local($this->app->publicPath() . '/assets'))]);
if (($path = $this->settings->get('favicon_path')) && $mount->has($file = "target://{$path}")) {
$mount->delete($file);
}
$uploadName = 'favicon-' . Str::lower(Str::quickRandom(8)) . '.' . $extension;
$mount->move('source://' . pathinfo($tmpFile, PATHINFO_BASENAME), "target://{$uploadName}");
$this->settings->set('favicon_path', $uploadName);
return parent::data($request, $document);
}
示例6: slug
public static function slug($name)
{
$extension = self::getExtension($name);
$name = str_replace($extension, '', $name);
$name = Str::slug($name);
return $name . strtolower($extension);
}
示例7: env
/**
* Gets the value of an environment variable. Supports boolean, empty and null.
*
* @param string $key
* @param mixed $default
*
* @return mixed
*/
function env($key, $default = null)
{
$value = getenv($key);
if ($value === false) {
return value($default);
}
switch (strtolower($value)) {
case 'true':
case '(true)':
return true;
case 'false':
case '(false)':
return false;
case 'empty':
case '(empty)':
return '';
case 'null':
case '(null)':
return;
}
if (strlen($value) > 1 && Str::startsWith($value, '"') && Str::endsWith($value, '"')) {
return substr($value, 1, -1);
}
return $value;
}
示例8: upload
/**
* Upload un torrent
*
* @access public
* @return View torrent.upload
*
*/
public function upload()
{
$user = Auth::user();
// Post et fichier upload
if (Request::isMethod('post')) {
// No torrent file uploaded OR an Error has occurred
if (Input::hasFile('torrent') == false) {
Session::put('message', 'You must provide a torrent for the upload');
return View::make('torrent.upload', array('categories' => Category::all(), 'user' => $user));
} else {
if (Input::file('torrent')->getError() != 0 && Input::file('torrent')->getClientOriginalExtension() != 'torrent') {
Session::put('message', 'An error has occurred');
return View::make('torrent.upload', array('categories' => Category::all(), 'user' => $user));
}
}
// Deplace et decode le torrent temporairement
TorrentTools::moveAndDecode(Input::file('torrent'));
// Array from decoded from torrent
$decodedTorrent = TorrentTools::$decodedTorrent;
// Tmp filename
$fileName = TorrentTools::$fileName;
// Info sur le torrent
$info = Bencode::bdecode_getinfo(getcwd() . '/files/torrents/' . $fileName, true);
// Si l'announce est invalide ou si le tracker et privée
if ($decodedTorrent['announce'] != route('announce', ['passkey' => $user->passkey]) && Config::get('other.freeleech') == true) {
Session::put('message', 'Your announce URL is invalid');
return View::make('torrent.upload', array('categories' => Category::all(), 'user' => $user));
}
// Find the right category
$category = Category::find(Input::get('category_id'));
// Create the torrent (DB)
$torrent = new Torrent(['name' => Input::get('name'), 'slug' => Str::slug(Input::get('name')), 'description' => Input::get('description'), 'info_hash' => $info['info_hash'], 'file_name' => $fileName, 'num_file' => $info['info']['filecount'], 'announce' => $decodedTorrent['announce'], 'size' => $info['info']['size'], 'nfo' => Input::hasFile('nfo') ? TorrentTools::getNfo(Input::file('nfo')) : '', 'category_id' => $category->id, 'user_id' => $user->id]);
// Validation
$v = Validator::make($torrent->toArray(), $torrent->rules);
if ($v->fails()) {
if (file_exists(getcwd() . '/files/torrents/' . $fileName)) {
unlink(getcwd() . '/files/torrents/' . $fileName);
}
Session::put('message', 'An error has occured may bee this file is already online ?');
} else {
// Savegarde le torrent
$torrent->save();
// Compte et sauvegarde le nombre de torrent dans cette catégorie
$category->num_torrent = Torrent::where('category_id', '=', $category->id)->count();
$category->save();
// Sauvegarde les fichiers que contient le torrent
$fileList = TorrentTools::getTorrentFiles($decodedTorrent);
foreach ($fileList as $file) {
$f = new TorrentFile();
$f->name = $file['name'];
$f->size = $file['size'];
$f->torrent_id = $torrent->id;
$f->save();
unset($f);
}
return Redirect::route('torrent', ['slug' => $torrent->slug, 'id' => $torrent->id])->with('message', trans('torrent.your_torrent_is_now_seeding'));
}
}
return View::make('torrent.upload', array('categories' => Category::all(), 'user' => $user));
}
示例9: initValidator
protected function initValidator()
{
$class = $this->getValidatorClass();
if ($class) {
$validator = new $class();
$this->validator_messages = $validator->messages();
$this->validator_rules = $validator->rules();
foreach ($this->validator_rules as $element_name => $element_rules) {
if (false !== mb_strpos($element_name, '.')) {
$element_name = str_replace('.', '][', $element_name) . ']';
$e = explode(']', $element_name, 2);
$element_name = implode('', $e);
}
foreach ($this->getElementsByName($element_name) as $el) {
$element_rules = explode('|', $element_rules);
foreach ($element_rules as $rule) {
$_rule = explode(':', $rule);
$rule_name = Arr::get($_rule, 0);
$rule_params = Arr::get($_rule, 1);
$rule_params = explode(',', $rule_params);
$method = Str::camel('rule_' . $rule_name);
if (method_exists($el, $method)) {
call_user_func_array([$el, $method], $rule_params);
}
}
}
}
}
return $this;
}
示例10: token
/**
* Generates a random token
*
* @param String $str [description]
*
* @return String [description]
*/
function token($str = null)
{
$str = isset($str) ? $str : \Illuminate\Support\Str::random();
$value = str_shuffle(sha1($str . microtime(true)));
$token = hash_hmac('sha1', $value, env('APP_KEY'));
return $token;
}
示例11: getRandomKey
/**
* Generate a random key for the application.
*
* @param string $cipher
* @return string
*/
protected function getRandomKey($cipher)
{
if ($cipher === 'AES-128-CBC') {
return Str::random(16);
}
return Str::random(32);
}
示例12: initVariables
public function initVariables()
{
$this->modelNamePlural = Str::plural($this->modelName);
$this->modelNameCamel = Str::camel($this->modelName);
$this->modelNamePluralCamel = Str::camel($this->modelNamePlural);
$this->initDynamicVariables();
}
示例13: setNameAttribute
public function setNameAttribute($value)
{
$this->attributes['name'] = trim($value);
if (!$this->slug) {
$this->attributes['slug'] = Str::slug($value);
}
}
示例14: run
public function run()
{
$films = [];
$faker = Faker\Factory::create('es_MX');
for ($i = 0; $i < self::AMOUNT; $i++) {
$film = array();
$film['title'] = implode(' ', $faker->words(rand(3, 6)));
$film['slug'] = \Illuminate\Support\Str::slug($film['title']) . '-' . rand(0, 4);
$film['original_title'] = 'Original' . $film['title'];
$film['years'] = self::getListOfYears();
$film['duration'] = $faker->time();
$film['genre_id'] = rand(0, 10);
$film['director'] = self::getListOfNames($faker);
$film['script'] = self::getListOfNames($faker);
$film['photographic'] = self::getListOfNames($faker);
$film['music'] = self::getListOfNames($faker);
$film['edition'] = self::getListOfNames($faker);
$film['production'] = self::getListOfNames($faker);
$film['cast'] = self::getListOfNames($faker);
$film['synopsis'] = $faker->paragraphs(rand(1, 5), true);
$film['notes'] = $faker->paragraphs(rand(0, 6), true);
$film['trailer'] = '<iframe width="560" height="315" src="https://www.youtube.com/embed/Gjg_Mi0zLlg" frameborder="0" allowfullscreen></iframe>';
$film['created_at'] = new DateTime();
$film['updated_at'] = new DateTime();
array_push($films, $film);
}
DB::table('films')->truncate();
DB::table('films')->insert($films);
}
示例15: retrieveByCredentials
/**
* Retrieve a user by the given credentials.
*
* @param array $credentials
* @return \Illuminate\Contracts\Auth\Authenticatable|null
*/
public function retrieveByCredentials(array $credentials)
{
if (empty($credentials)) {
return null;
}
$index = null;
$values = null;
foreach ($credentials as $key => $value) {
if (!Str::contains($key, 'password')) {
$index = is_null($index) ? $key : $index . '_' . $key;
$values = is_null($values) ? [] : $values;
$values[] = $value;
}
}
if (is_null($index) || is_null($values)) {
return null;
}
$values = count($values) == 1 ? $values[0] : $values;
$result = $this->createModel()->newQuery()->getQuery()->r()->getAll($values, ['index' => $index])->run();
$result = $this->hydrate($result);
if ($result) {
$result = $result->first();
}
return $result;
}