Assume we have a company table and there is a field like a company name. Now we want to seed data in laravel using database seeder to generate some fake companies for the company table. To do that, we can use company() helper. I will show you the example of faker company name laravel.

So if you are looking for faker company name laravel then this tutorial is for you. So let's see the example code of faker company name laravel:

<?php

use App\Models\Customer;
use Faker\Factory as Faker;
use Illuminate\Database\Seeder;

class CompanySeeder extends Seeder
{
    /**
     * Run the database seeds.
     *
     * @return void
     */
    public function run()
    {

        $faker = Faker::create();

        for ($i=1; $i < 101 ; $i++) { 
            $company = new Company;
            $company->name = $faker->company;
            $company->save();
        }  
    }
}

 

If you are in Laravel 9 version, then you can use like this:

<?php

namespace Database\Factories;

use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Support\Str;

/**
 * @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\User>
 */
class CompanyFactory extends Factory
{
    public function definition()
    {
        return [
            'name' => fake()->company()
        ];
    }
}

 

See all the available faker company helpers from below:

catchPhrase             // 'Monitored regional contingency'
bs                      // 'e-enable robust architectures'
company                 // 'Bogan-Treutel'
companySuffix           // 'and Sons'
jobTitle                // 'Cashier'

 

Read also: Laravel Factory Faker Address Example

 

Conclusion

I have tried to discuss the clear concept of faker company name laravel. Now we know laravel faker company name. Hope this laravel faker company tutorial will help you.