PHP code example of bishwajitcadhikary / laravel-faker-extended

1. Go to this page and download the library: Download bishwajitcadhikary/laravel-faker-extended library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

bishwajitcadhikary / laravel-faker-extended example snippets


// Use in a factory or seeder
$faker = app(\Faker\Generator::class);

// Get a job title
$jobTitle = $faker->jobTitle(); // 'Senior Software Engineer'

// Get personality traits
$trait = $faker->personalityTraits(); // 'Analytical'
$traits = $faker->personalityTraits(3); // ['Creative', 'Detail-oriented', 'Innovative']

// Get a personality profile
$profile = $faker->personalityProfile();
// [
//     'strengths' => ['Analytical', 'Creative'],
//     'weaknesses' => ['Perfectionist'],
//     'mbti' => 'INTJ'
// ]

// Get an age
$age = $faker->age(25, 45); // 32

// Get a company type
$companyType = $faker->companyType(); // 'LLC'

// Get a business sector
$sector = $faker->sector(); // 'Technology'

// Get a mission statement
$mission = $faker->missionStatement(15); // 'Our mission is to...'

// Get company values
$value = $faker->companyValues(1); // 'Innovation'
$values = $faker->companyValues(3); // ['Integrity', 'Teamwork', 'Excellence']

// Get funding information
$fundingRound = $faker->fundingRound(); // 'Series A'
$fundingAmount = $faker->fundingAmount(5, 20); // '$12.5M'
$fundingInfo = $faker->fundingInfo();
// [
//     'round' => 'Series A',
//     'amount' => '$12.5M',
//     'investors' => 3,
//     'valuation' => '$75M',
//     'date' => '2023-05-15'
// ]

// Get a social media handle
$handle = $faker->socialMediaHandle(); // '@johndoe'

// Get a social media platform
$platform = $faker->socialPlatform(); // 'Twitter'

// Get social profiles
$profiles = $faker->socialProfiles(2);
// [
//     'Twitter' => '@johndoe',
//     'LinkedIn' => '@johndoe'
// ]

// Get programming languages
$language = $faker->programmingLanguage(); // 'Python'
$languages = $faker->programmingLanguages(3); // ['JavaScript', 'Python', 'PHP']

// Get tech stack
$techStack = $faker->techStack();
// [
//     'frontend' => 'React',
//     'backend' => 'Laravel',
//     'database' => 'PostgreSQL',
//     'languages' => ['JavaScript', 'PHP', 'Python']
// ]

// Get a startup hub
$hub = $faker->startupHub(); // 'San Francisco'

// Get a neighborhood
$neighborhood = $faker->neighborhood(); // 'Financial District'

// Get a complete office location
$officeLocation = $faker->officeLocation();
// [
//     'type' => 'Headquarters',
//     'building' => '123',
//     'street' => 'Main St',
//     'neighborhood' => 'Financial District',
//     'city' => 'San Francisco',
//     'zipcode' => '94105',
//     'country' => 'United States',
//     'coordinates' => [
//         'latitude' => 37.7749,
//         'longitude' => -122.4194
//     ]
// ]

// Get company locations
$locations = $faker->companyLocations(2);
// [
//     [
//         'city' => 'San Francisco',
//         'type' => 'Headquarters',
//         'employees' => 250
//     ],
//     [
//         'city' => 'New York',
//         'type' => 'Sales Office',
//         'employees' => 30
//     ]
// ]

// Get a degree
$degree = $faker->degree(); // 'Bachelor of Science'

// Get a field of study
$field = $faker->fieldOfStudy(); // 'Computer Science'

// Get a university
$university = $faker->university(); // 'Harvard University'

// Get an education history
$education = $faker->educationHistory(2);
// [
//     [
//         'degree' => 'Bachelor of Science',
//         'field' => 'Computer Science',
//         'university' => 'Stanford University',
//         'startYear' => 2014,
//         'endYear' => 2018,
//         'gpa' => '3.8/4.0'
//     ],
//     [
//         'degree' => 'Master of Business Administration',
//         'field' => 'Finance',
//         'university' => 'Harvard University',
//         'startYear' => 2018,
//         'endYear' => 2020,
//         'gpa' => '3.9/4.0'
//     ]
// ]

// Get skills
$skill = $faker->skill('Technical'); // 'Programming'
$skillSet = $faker->skillSet(3);
// [
//     ['name' => 'Programming', 'category' => 'Technical'],
//     ['name' => 'Communication', 'category' => 'Soft Skills'],
//     ['name' => 'Project Management', 'category' => 'Business']
// ]

// Get an inspirational quote
$quote = $faker->inspirationalQuote();
// ['quote' => 'The only way to do great work is to love what you do.', 'author' => 'Steve Jobs']

// Get just the quote text without author
$quoteText = $faker->inspirationalQuote(false);
// 'The only way to do great work is to love what you do.'

// Get specific quote types
$businessQuote = $faker->businessQuote();
$technologyQuote = $faker->technologyQuote();
$leadershipQuote = $faker->leadershipQuote();
$movieQuote = $faker->movieQuote();
$programmingQuote = $faker->programmingQuote();

// Get a random quote of any type
$randomQuote = $faker->randomQuote();
// [
//     'quote' => 'First, solve the problem. Then, write the code.',
//     'author' => 'John Johnson',
//     'type' => 'programming'
// ]

// Get multiple quotes
$quotes = $faker->quotes(3, 'business', true);
// Array of 3 business quotes with authors

// Get multiple quotes of random types
$randomQuotes = $faker->quotes(5);
// Array of 5 random quotes of different types

namespace Database\Factories;

use App\Models\User;
use Illuminate\Database\Eloquent\Factories\Factory;

class UserFactory extends Factory
{
    protected $model = User::class;

    public function definition()
    {
        return [
            'name' => $this->faker->name(),
            'email' => $this->faker->unique()->safeEmail(),
            'job_title' => $this->faker->jobTitle(),
            'personality' => $this->faker->personalityTraits(3),
            'favorite_quote' => $this->faker->inspirationalQuote(),
            'skills' => $this->faker->skillSet(5),
            'education' => $this->faker->educationHistory(2),
        ];
    }
}