php-fakerHow can I use Laravel Faker to generate boolean values?
You can use Laravel Faker to generate boolean values by using the boolean() method.
Example code
$booleanValue = Faker\Factory::create()->boolean();
Output example
true
The boolean() method generates a random boolean value of either true or false. It takes no parameters.
Code explanation
Faker\Factory::create()
- creates a new Faker\Generator instanceboolean()
- generates a random boolean value
Helpful links
More of Php Faker
- How do I generate a zip file using PHP Faker?
- How can I generate a zip code using Laravel Faker?
- How can I generate fake data in XLSX format using PHP Faker?
- How do I generate a random zip code using PHP Faker?
- How can I specify the word length when using Laravel Faker?
- How do I set the locale for PHP Faker?
- How do I generate a fake year in Laravel using Faker?
- How do I check which version of Laravel Faker I am using?
- How do I generate a valid VAT number using Laravel Faker?
- How can I generate unique data with Laravel Faker?
See more codes...