本文整理汇总了PHP中Func::getHashedValue方法的典型用法代码示例。如果您正苦于以下问题:PHP Func::getHashedValue方法的具体用法?PHP Func::getHashedValue怎么用?PHP Func::getHashedValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Func
的用法示例。
在下文中一共展示了Func::getHashedValue方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: passwordResetAPI
public function passwordResetAPI()
{
$request = \App::make('request');
$to_email = $request->email;
$user = $this->model->where('email', '=', $to_email)->first();
$hashSeed = rand();
$new_password = substr(\Func::getHashedValue($hashSeed), 0, 6);
$user->password = bcrypt($new_password);
Mail::send('emails.password_reset', ['user_info' => $user, 'new_password' => $new_password], function ($message) use($to_email) {
$message->from('info@snaplook.today', 'Snaplook');
$message->to($to_email)->subject('[Snaplook] Here is your temporary Password.');
});
$user->save();
return;
}
示例2: storeAPI
public function storeAPI()
{
\DB::beginTransaction();
try {
// post save
$post = $this->model->create(array('user_id' => $_POST['user_id'], 'content' => $_POST['captions']));
if (!$post) {
\DB::rollback();
return;
}
$post_group = $this->post_group->where('post_groups.user_id', '=', $_POST['user_id'])->where('post_groups.name', '=', "Uncategorized")->first();
$post->postGroups()->attach($post_group->id);
$types = array('_o.', '_s.', '_m.', '_l.');
$sizes = array(100, 300, 600);
$target_path = base_path() . '/public/imgs/';
$file = \Input::file('image');
$hashSeed = "post" . $post->id . $file->getClientOriginalName();
while (1) {
$file_name = \Func::getHashedValue($hashSeed);
if (!\File::exists($target_path . \Func::getImgPath($file_name))) {
break;
}
$hashSeed .= rand();
}
$target_path .= \Func::getImgPath($file_name) . '/';
if (!\File::exists($target_path)) {
\File::makeDirectory($target_path, 0775, true);
}
$file_ext = $file->getClientOriginalExtension();
$original = $file_name . array_shift($types) . $file_ext;
$file->move($target_path, $original);
// Move the original one first
foreach ($types as $key => $type) {
$new_name = $file_name . $type . $file_ext;
\File::copy($target_path . $original, $target_path . $new_name);
\Image::make($target_path . $new_name)->resize($sizes[$key], null, function ($constraint) {
$constraint->aspectRatio();
$constraint->upsize();
})->save($target_path . $new_name);
}
\File::delete($target_path . $original);
$photo = $this->photo->create(array('post_id' => $post->id, 'sequence' => 1, 'img_path' => $file_name . '.' . $file_ext));
if (!$photo) {
\DB::rollback();
return;
}
// hash tag save
$temp = $_POST['captions'];
preg_match_all('/#(\\w+)/', $temp, $matches);
$hashtags = $matches[1];
foreach ($hashtags as $hashtag) {
$tag = $this->tag->firstOrCreate(['name' => $hashtag]);
$post->Tags()->attach($tag->id);
}
$this->common_func->storeActivityLogWithUser('store_post', $post->id, 'post', $_POST['user_id']);
} catch (ValidationException $e) {
\DB::rollback();
} catch (\Exception $e) {
\DB::rollback();
throw $e;
}
\DB::commit();
return $post;
}