How to Generate Random Unique String in Laravel?
Laravel provide several string helper that way we can use it easily like str_limit, str_plural, str_finish, str_singular etc. If you need to generate unique random string then you can use str_random() helper of Laravel. It is very simple and you can use easily.
you can easily generate random string in laravel 6, laravel 7 and laravel 8 version using str helper.
str_random() helper take one numeric argument and return number of unique string that you pass as argument. you can see it's syntax and example:
class GoogleController extends Controller
* Create a new controller instance.
* @return void
public function index()
$randomString = Str::random(30);
I hope it can help you...
We are Recommending you
- Laravel Model Events Tutorial
- Laravel Eloquent take() and skip() Query Example
- Laravel Unique Validation on Update Example
- Special Characters Not Allowed Validation in Laravel
- How to Change Table Name using Laravel Migration?
- PHP Laravel - How to Check if a String Contains a Specific Word?
- How to generate route with query string parameter in Laravel 5?
- How to Get Query Strings Value in Laravel?
- Mysql procedure with pagination in laravel?