Home > Software engineering >  Laravel specific format random string
Laravel specific format random string

Time:11-01

how can I create random string in Laravel like this

df5bd363-7bb3-4ab7-bc51-92a377e9bfda&VstCode=27621521869

I need the dashes and the '&VstCode=' not dynamic and fixed in every string generated

CodePudding user response:

The first part of the string looks and smells like an UUID. The latter part, i would just hardcode, that could be an argument query params should be handled by either an URL builder, Guzzle or similar. But in practical terms, i would solve your problem like this in most cases.

use Ramsey\Uuid\Uuid;   

public function generateString() {
    return Uuid::uuid4() . '&VstCode=27621521869';
}

I ran this code in tinker, it provided the following result.

386da289-0655-46ac-adc4-9cc54583cd22&VstCode=27621521869
  • Related