Home > Back-end >  How with faker to get text without ending “.”?
How with faker to get text without ending “.”?

Time:05-15

When in laravel 9 app I set value for text field with faker :

 $this->faker->unique()->text(25);

I see text for field ending with “.”. How can I get text without ending “.” ?

"laravel/framework": "^9.11",
"fakerphp/faker": "^1.9.1",

Thanks.

CodePudding user response:

The author of the library decided not to implement this feature: https://github.com/fzaninotto/Faker/issues/1128

You can do it like:

substr(str_replace('.', '', $this->faker->unique()->text(25)), 0, 25);

You can adjust this to replace with specific symbol, if you need to have exactly 25 chars.

  • Related