Laravel: Generate random unique token

Posted by pavan - 1 year ago

Laravel: Generate random unique token

laravel 6 generate unique token

use Illuminate\Support\Str;

public function yourFunction(){
 $var = Str::random(45);

 dump($var);
}

Laravel generate random unique string example

Syntax:

str_random(number);

Example:

$randomString = str_random(25);

dd($randomString);

Output:

8BXYr78JdV1T4DKmTYvc0WLfM