Skip to content

Instantly share code, notes, and snippets.

@bayareawebpro
Last active August 21, 2017 21:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bayareawebpro/51a98f83d12c5d4f63849554f4569a90 to your computer and use it in GitHub Desktop.
Save bayareawebpro/51a98f83d12c5d4f63849554f4569a90 to your computer and use it in GitHub Desktop.
<?php
$user = User::first($id)
//Generate Token
do {
$token = str_random(128);
} while (User::where('token', $token)->exists());
$user->token = $token;
$user->save();
//Check Token
if(User::where('token', $token)->exists()){
$user = User::where('token', $token)->first();
//Do Something
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment