Skip to content
A collection of custom Faker providers for your Laravel applications
PHP
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
src
.gitignore
LICENSE
README.md
composer.json

README.md

laravel-faker-provider-collection

This package contains a Service Provider that automatically registers the faker-provider-collection library with your Laravel application.

Detailed information about the various Faker providers exposed by faker-provider-collection can be found here.

Quickstart

Add the provider to your Laravel project via Composer:

composer require --dev mbezhanov/laravel-faker-provider-collection

You should now be able to use the all the extra providers bundled with this library in your Model Factories

In example, assuming you have defined the following model factory:

<?php

// ./database/factories/StudentFactory.php

use Faker\Generator as Faker;

$factory->define(App\Models\Student::class, function (Faker $faker) {
    return [
        'university' => $faker->university,
        'sport' => $faker->sport,
        'team' => $faker->team,
    ];
});

You should be able to do:

/app # php artisan tinker
Psy Shell v0.8.17 (PHP 7.1.10 — cli) by Justin Hileman
>>> factory(App\Models\Student::class, 5)->create();
=> Illuminate\Database\Eloquent\Collection {#1300
     all: [
       App\Models\Student {#1296
         university: "Ostbarrow Technical College",
         sport: "rugby",
         team: "Tennessee Foes",
         updated_at: "2018-10-04 08:25:49",
         created_at: "2018-10-04 08:25:49",
         id: 1,
       },
       App\Models\Student {#1294
         university: "Vertapple Technical College",
         sport: "baseball",
         team: "Alabama Bees",
         updated_at: "2018-10-04 08:25:49",
         created_at: "2018-10-04 08:25:49",
         id: 2,
       },
       App\Models\Student {#1292
         university: "Iceborough TAFE",
         sport: "soccer",
         team: "Arkansas Bees",
         updated_at: "2018-10-04 08:25:50",
         created_at: "2018-10-04 08:25:50",
         id: 3,
       },
       App\Models\Student {#1291
         university: "Flowerlake College",
         sport: "hockey",
         team: "North Dakota Fishes",
         updated_at: "2018-10-04 08:25:50",
         created_at: "2018-10-04 08:25:50",
         id: 4,
       },
       App\Models\Student {#1293
         university: "Brighthurst Technical College",
         sport: "lacrosse",
         team: "Virginia Zombies",
         updated_at: "2018-10-04 08:25:50",
         created_at: "2018-10-04 08:25:50",
         id: 5,
       },
     ],
   }
>>> exit
Exit:  Goodbye.
/app # 
You can’t perform that action at this time.