当前位置: 首页>>代码示例>>PHP>>正文


PHP Str::quickRandom方法代码示例

本文整理汇总了PHP中Illuminate\Support\Str::quickRandom方法的典型用法代码示例。如果您正苦于以下问题:PHP Str::quickRandom方法的具体用法?PHP Str::quickRandom怎么用?PHP Str::quickRandom使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Illuminate\Support\Str的用法示例。


在下文中一共展示了Str::quickRandom方法的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.');
     }
 }
开发者ID:unicorn-softwares,项目名称:employment_bank,代码行数:31,代码来源:AdminHomeController.php

示例2: handle

 /**
  * @param UploadAvatar $command
  * @return \Flarum\Core\User
  * @throws \Flarum\Core\Exception\PermissionDeniedException
  */
 public function handle(UploadAvatar $command)
 {
     $actor = $command->actor;
     $user = $this->users->findOrFail($command->userId);
     if ($actor->id !== $user->id) {
         $this->assertCan($actor, 'edit', $user);
     }
     $tmpFile = tempnam($this->app->storagePath() . '/tmp', 'avatar');
     $command->file->moveTo($tmpFile);
     $file = new UploadedFile($tmpFile, $command->file->getClientFilename(), $command->file->getClientMediaType(), $command->file->getSize(), $command->file->getError(), true);
     $this->validator->assertValid(['avatar' => $file]);
     $manager = new ImageManager();
     $manager->make($tmpFile)->fit(100, 100)->save();
     $this->events->fire(new AvatarWillBeSaved($user, $actor, $tmpFile));
     $mount = new MountManager(['source' => new Filesystem(new Local(pathinfo($tmpFile, PATHINFO_DIRNAME))), 'target' => $this->uploadDir]);
     if ($user->avatar_path && $mount->has($file = "target://{$user->avatar_path}")) {
         $mount->delete($file);
     }
     $uploadName = Str::lower(Str::quickRandom()) . '.jpg';
     $user->changeAvatarPath($uploadName);
     $mount->move("source://" . pathinfo($tmpFile, PATHINFO_BASENAME), "target://{$uploadName}");
     $user->save();
     $this->dispatchEventsFor($user, $actor);
     return $user;
 }
开发者ID:asifalimd,项目名称:core,代码行数:30,代码来源:UploadAvatarHandler.php

示例3: handle

 /**
  * @param UploadAvatar $command
  * @return \Flarum\Core\Users\User
  * @throws \Flarum\Core\Exceptions\PermissionDeniedException
  */
 public function handle(UploadAvatar $command)
 {
     $actor = $command->actor;
     $user = $this->users->findOrFail($command->userId);
     // Make sure the current user is allowed to edit the user profile.
     // This will let admins and the user themselves pass through, and
     // throw an exception otherwise.
     if ($actor->id !== $user->id) {
         $user->assertCan($actor, 'edit');
     }
     $tmpFile = tempnam(sys_get_temp_dir(), 'avatar');
     $command->file->moveTo($tmpFile);
     $manager = new ImageManager();
     $manager->make($tmpFile)->fit(100, 100)->save();
     event(new AvatarWillBeSaved($user, $actor, $tmpFile));
     $mount = new MountManager(['source' => new Filesystem(new Local(pathinfo($tmpFile, PATHINFO_DIRNAME))), 'target' => $this->uploadDir]);
     if ($user->avatar_path && $mount->has($file = "target://{$user->avatar_path}")) {
         $mount->delete($file);
     }
     $uploadName = Str::lower(Str::quickRandom()) . '.jpg';
     $user->changeAvatarPath($uploadName);
     $mount->move("source://" . pathinfo($tmpFile, PATHINFO_BASENAME), "target://{$uploadName}");
     $user->save();
     $this->dispatchEventsFor($user);
     return $user;
 }
开发者ID:redstarxz,项目名称:flarumone,代码行数:31,代码来源:UploadAvatarHandler.php

示例4: 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);
 }
开发者ID:flarum,项目名称:core,代码行数:28,代码来源:UploadFaviconController.php

示例5: store

 /**
  * Create a document.
  *
  * @param DocumentRequest $request
  *
  * @return \Illuminate\Http\RedirectResponse
  */
 public function store(DocumentRequest $request)
 {
     $document = new Document($request->only(['group', 'published']));
     $document->save();
     $attachment = $document->attachments()->save(new Attachment(['name' => $request->input('name'), 'file_name' => Str::quickRandom(6) . '.' . $request->file('attachment')->guessExtension(), 'mime_type' => $request->file('attachment')->getMimeType(), 'size' => $request->file('attachment')->getSize()]));
     $request->file('attachment')->move($attachment->getDirectory(), $attachment->getAttribute('file_name'));
     return Response::redirectToRoute('documents.index');
 }
开发者ID:BePsvPT,项目名称:CCUSA,代码行数:15,代码来源:DocumentController.php

示例6: saveImage

 public function saveImage($tmpFile)
 {
     $dir = date('Ym/d');
     $mount = new MountManager(['source' => new Filesystem(new LocalFS(pathinfo($tmpFile, PATHINFO_DIRNAME))), 'target' => new Filesystem(new LocalFS(public_path('assets/uploads')))]);
     $uploadName = Str::lower(Str::quickRandom()) . '.jpg';
     $mount->move("source://" . pathinfo($tmpFile, PATHINFO_BASENAME), "target://{$dir}/{$uploadName}");
     return $this->config['urlPrefix'] . 'uploads/' . $dir . '/' . $uploadName;
 }
开发者ID:redstarxz,项目名称:flarumone,代码行数:8,代码来源:Local.php

示例7: store

 /**
  * Create a new zinc.
  *
  * @param ZincRequest $request
  *
  * @return \Illuminate\Http\RedirectResponse
  */
 public function store(ZincRequest $request)
 {
     $zinc = Zinc::create(array_merge($request->only(['year', 'month', 'topic']), $this->getPublished($request)));
     foreach ($request->file('image', []) as $file) {
         $zinc->addMedia($file)->setFileName(Str::quickRandom(8) . '.' . $file->guessExtension())->toCollection('images-zinc', 'media.zinc');
     }
     return redirect()->route('zinc.manage.index');
 }
开发者ID:BePsvPT,项目名称:CCUSA,代码行数:15,代码来源:ManageController.php

示例8: put

 public function put($contents, $callback, $extension = '')
 {
     $path = $this->tempPath . '/' . Str::quickRandom(32) . $extension;
     $this->filesystem->put($path, $contents);
     $result = $callback($path);
     $this->filesystem->delete($path);
     return $result;
 }
开发者ID:tightenco,项目名称:jigsaw,代码行数:8,代码来源:TemporaryFilesystem.php

示例9: saveImage

 public function saveImage($tmpFile)
 {
     $upManager = new UploadManager();
     $auth = new Auth($this->config['accessToken'], $this->config['secretToken']);
     $token = $auth->uploadToken($this->config['bucketName']);
     $uploadName = date('Y/m/d/') . Str::lower(Str::quickRandom()) . '.jpg';
     list($ret, $error) = $upManager->put($token, $uploadName, file_get_contents($tmpFile));
     if (!$ret) {
         throw new Exception($error->message());
     }
     return rtrim($this->config['baseUrl'], '/') . '/' . $uploadName;
 }
开发者ID:redstarxz,项目名称:flarumone,代码行数:12,代码来源:Qiniu.php

示例10: saveImage

 public function saveImage($tmpFile)
 {
     $resp = [];
     $filename = date('Y/m/d/') . Str::quickRandom() . '.jpg';
     try {
         $resp = $this->http->request('PUT', $filename, ['header' => ['mkdir' => true], 'body' => fopen($tmpFile, 'r')]);
     } catch (RequestException $e) {
         $resp = $e->getResponse();
         throw new Exception('HTTP ' . $resp->getStatusCode() . ' ' . $resp->getReasonPhrase() . "\n" . $resp->getBody()->getContents());
     }
     return rtrim($this->config['baseUrl'], '/') . '/' . $filename;
 }
开发者ID:redstarxz,项目名称:flarumone,代码行数:12,代码来源:Upyun.php

示例11: newDemoUser

 /**
  * Set up a new demo user and log in.
  *
  * @return BackendAuth
  */
 protected function newDemoUser()
 {
     $demoManager = DemoManager::instance();
     $login = Str::quickRandom(Config::get('krisawzm.demomanager::username_length', 10));
     if (!$demoManager->copyTheme($login)) {
         return false;
     }
     $user = User::create(['email' => $login . '@' . $login . '.tld', 'login' => $login, 'password' => $login, 'password_confirmation' => $login, 'first_name' => ucfirst($login), 'last_name' => 'Demo', 'permissions' => $this->getPermissions(), 'is_activated' => true]);
     BackendAuth::login($user);
     UserCounter::instance()->inc();
     return $user;
 }
开发者ID:janusnic,项目名称:demomanager-plugin,代码行数:17,代码来源:DemoAuth.php

示例12: setAttribute

 /**
  *  Hijack Eloquent's setAttribute to create a Language Entry, or update the existing one, when setting the value of this attribute.
  *
  *  @param  string  $attribute    Attribute name
  *  @param  string  $value  Text value in default locale.
  *  @return void
  */
 public function setAttribute($attribute, $value)
 {
     if ($this->isTranslatable($attribute) && !empty($value)) {
         // If a translation code has not yet been set, generate one:
         if (!$this->translationCodeFor($attribute)) {
             $reflected = new \ReflectionClass($this);
             $group = 'translatable';
             $item = strtolower($reflected->getShortName()) . '.' . strtolower($attribute) . '.' . Str::quickRandom();
             $this->attributes["{$attribute}_translation"] = "{$group}.{$item}";
         }
     }
     return parent::setAttribute($attribute, $value);
 }
开发者ID:MarkRedeman,项目名称:translation,代码行数:20,代码来源:Translatable.php

示例13: handleProviderCallback

 /**
  * Obtain the user information from GitHub.
  *
  * @return Response
  */
 public function handleProviderCallback($provider)
 {
     $providerUser = Socialite::driver($provider)->user();
     $user = User::firstOrNew(['email' => $providerUser->getEmail()]);
     if (!$user->exists) {
         $user->first_name = $providerUser->user['name']['givenName'];
         $user->last_name = $providerUser->user['name']['familyName'];
         $user->password = bcrypt(\Illuminate\Support\Str::quickRandom());
         $user->save();
     }
     try {
         Auth::login($user, true);
     } catch (Exception $ex) {
         return redirect()->intended('/');
     }
     return redirect()->intended('home');
 }
开发者ID:GingerCodes,项目名称:smart-wallet,代码行数:22,代码来源:AuthController.php

示例14: handle

 public function handle(Request $request)
 {
     $images = $request->http->getUploadedFiles()['images'];
     $results = [];
     foreach ($images as $image_key => $image) {
         $tmpFile = tempnam(sys_get_temp_dir(), 'image');
         $image->moveTo($tmpFile);
         $urlGenerator = app('Flarum\\Http\\UrlGeneratorInterface');
         $dir = 'uploads/' . date('Ym/d');
         $path = './assets/' . $dir;
         $mount = new MountManager(['source' => new Filesystem(new Local(pathinfo($tmpFile, PATHINFO_DIRNAME))), 'target' => new Filesystem(new Local($path))]);
         $uploadName = Str::lower(Str::quickRandom()) . '.jpg';
         $mount->move("source://" . pathinfo($tmpFile, PATHINFO_BASENAME), "target://{$uploadName}");
         $results['img_' . $image_key] = Core::url() . '/assets/' . $dir . '/' . $uploadName;
     }
     return new JsonResponse($results);
 }
开发者ID:stoensin,项目名称:flarumone,代码行数:17,代码来源:UploadAction.php

示例15: getFiles

 protected function getFiles($type, Closure $callback)
 {
     $dir = $this->getAssetDirectory();
     if (!($revision = $this->getRevision())) {
         $revision = Str::quickRandom();
         $this->putRevision($revision);
     }
     $lastModTime = 0;
     foreach ($this->files[$type] as $file) {
         $lastModTime = max($lastModTime, filemtime($file));
     }
     $debug = 0;
     // $debug = 1;
     if (!file_exists($file = $dir . '/' . $this->name . '-' . $revision . '.' . $type) || filemtime($file) < $lastModTime || $debug) {
         $this->storage->put($file, $callback());
     }
     return [$file];
 }
开发者ID:Qiang1234,项目名称:core,代码行数:18,代码来源:AssetManager.php


注:本文中的Illuminate\Support\Str::quickRandom方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。