1use Illuminate\Support\Str;
2
3public function yourFunction(){
4 $var = Str::random(32);
5
6 dd($var);
7}
1'required|email|unique:company_users,email_address,NULL,id,company_id,' . $request->company_id
2
1function generateBarcodeNumber() {
2 $number = mt_rand(1000000000, 9999999999); // better than rand()
3
4 // call the same function if the barcode exists already
5 if (barcodeNumberExists($number)) {
6 return generateBarcodeNumber();
7 }
8
9 // otherwise, it's valid and can be used
10 return $number;
11}
12
13function barcodeNumberExists($number) {
14 // query the database and return a boolean
15 // for instance, it might look like this in Laravel
16 return User::whereBarcodeNumber($number)->exists();
17}
18