### Install via Composer Source: https://github.com/jeffersongoncalves/laravel-fake-cartoons/blob/master/README.md Install the package as a development dependency using Composer. ```bash composer require --dev jeffersongoncalves/laravel-fake-cartoons ``` -------------------------------- ### Install laravel-fake-cartoons with Composer Source: https://github.com/jeffersongoncalves/laravel-fake-cartoons/blob/master/resources/boost/skills/fake-cartoons-development/SKILL.md Installs the Laravel Fake Cartoons package. No additional setup is needed because the package auto-discovers via Laravel's package discovery. ```bash composer require jeffersongoncalves/laravel-fake-cartoons ``` -------------------------------- ### Dev Commands for Testing and Analysis Source: https://github.com/jeffersongoncalves/laravel-fake-cartoons/blob/master/resources/boost/skills/fake-cartoons-development/SKILL.md Development commands for running tests, static analysis, and code formatting. ```bash # Run tests vendor/bin/pest # Run static analysis vendor/bin/phpstan analyse # Format code vendor/bin/pint ``` -------------------------------- ### Creating a New Faker Provider (CartoonCharacterProvider) Source: https://github.com/jeffersongoncalves/laravel-fake-cartoons/blob/master/resources/boost/skills/fake-cartoons-development/SKILL.md Template for creating a new Faker provider. Extend Faker\Provider\Base, add a static array of values, and use static::randomElement() in a method. Register the provider in FakeCartoonsServiceProvider::packageRegistered(). ```php // Example: CartoonCharacterProvider class CartoonCharacterProvider extends Base { protected static $characters = ['Bugs Bunny', 'Homer Simpson', ...]; public function cartoonCharacter(): string { return static::randomElement(static::$characters); } } ``` -------------------------------- ### CartoonCompanyProvider with cartoonCompany method Source: https://github.com/jeffersongoncalves/laravel-fake-cartoons/blob/master/resources/boost/skills/fake-cartoons-development/SKILL.md The Faker provider extends Faker\Provider\Base and exposes a single method cartoonCompany() that returns a random element from the static list of cartoon company names. ```php // src/Faker/CartoonCompanyProvider.php class CartoonCompanyProvider extends Base { protected static $cartoonCompanies = [ 'ACME Corporation', 'Planet Express', 'Krusty Krab', 'Chum Bucket', 'Monsters, Inc.', 'Buy n Large', 'Springfield Nuclear Power Plant', 'Kwik-E-Mart', 'Pizza Planet', "Mom's Friendly Robot Company", "Al's Toy Barn", 'Blips and Chitz', 'Pawtucket Patriot Ale', 'Slurm', 'Insuricare', "Moe's Tavern", 'Wayne Enterprises', 'Stark Industries', 'Oscorp', ]; public function cartoonCompany(): string { return static::randomElement(static::$cartoonCompanies); } } ``` -------------------------------- ### Use in a Seeder Source: https://github.com/jeffersongoncalves/laravel-fake-cartoons/blob/master/README.md Use the provider in a seeder to create ten companies with cartoon names. ```php use Illuminate\Database\Seeder; class CompanySeeder extends Seeder { public function run(): void { foreach (range(1, 10) as $ignored) { Company::create([ 'name' => fake()->cartoonCompany(), ]); } } } ``` -------------------------------- ### Testing CartoonCompanyProvider Directly with Pest Source: https://github.com/jeffersongoncalves/laravel-fake-cartoons/blob/master/resources/boost/skills/fake-cartoons-development/SKILL.md Pest test that directly instantiates the provider and verifies the generated company is in the known list of 19 entries. ```php use JeffersonGoncalves\FakeCartoons\Faker\CartoonCompanyProvider; use Faker\Generator; it('returns a string from the cartoon companies list', function () { $faker = new Generator(); $faker->addProvider(new CartoonCompanyProvider($faker)); $company = $faker->cartoonCompany(); expect($company)->toBeString(); expect($company)->toBeIn([ 'ACME Corporation', 'Planet Express', 'Krusty Krab', // ... all 19 entries ]); }); ``` -------------------------------- ### Testing fake()->cartoonCompany() with Pest Source: https://github.com/jeffersongoncalves/laravel-fake-cartoons/blob/master/resources/boost/skills/fake-cartoons-development/SKILL.md Pest test that verifies the fake() helper returns a non-empty string for cartoonCompany(). ```php it('generates a cartoon company name', function () { $name = fake()->cartoonCompany(); expect($name)->toBeString()->not->toBeEmpty(); }); ``` -------------------------------- ### FakeCartoonsServiceProvider registers CartoonCompanyProvider Source: https://github.com/jeffersongoncalves/laravel-fake-cartoons/blob/master/resources/boost/skills/fake-cartoons-development/SKILL.md The service provider extends Spatie's PackageServiceProvider and registers the Faker provider automatically. The resolving callback ensures the provider is added every time a Faker\Generator instance is resolved from the container, including in factories and tests. ```php // src/FakeCartoonsServiceProvider.php class FakeCartoonsServiceProvider extends PackageServiceProvider { public function configurePackage(Package $package): void { $package->name('laravel-fake-cartoons'); } public function packageRegistered(): void { $this->app->resolving(Generator::class, function (Generator $faker) { $faker->addProvider(new CartoonCompanyProvider($faker)); }); } } ``` -------------------------------- ### Namespace structure of FakeCartoons Source: https://github.com/jeffersongoncalves/laravel-fake-cartoons/blob/master/resources/boost/skills/fake-cartoons-development/SKILL.md Shows the namespace structure of the package, with the main service provider and the Faker provider. ```text JeffersonGoncalves\FakeCartoons\ FakeCartoonsServiceProvider # Main service provider Faker\ CartoonCompanyProvider # Faker provider with cartoon companies ``` -------------------------------- ### Use in a Model Factory Source: https://github.com/jeffersongoncalves/laravel-fake-cartoons/blob/master/README.md Use the provider in a model factory to generate cartoon company names for database seeding. ```php use Illuminate\Database\Eloquent\Factories\Factory; class CompanyFactory extends Factory { public function definition(): array { return [ 'name' => fake()->cartoonCompany(), ]; } } ``` -------------------------------- ### Using fake()->cartoonCompany() in a Laravel Factory Source: https://github.com/jeffersongoncalves/laravel-fake-cartoons/blob/master/resources/boost/skills/fake-cartoons-development/SKILL.md Use in Laravel model factories to generate cartoon company names and emails. The fake() helper is available in the factory context. ```php use Illuminate\Database\Eloquent\Factories\Factory; class CompanyFactory extends Factory { public function definition(): array { return [ 'name' => fake()->cartoonCompany(), 'email' => fake()->companyEmail(), ]; } } ``` -------------------------------- ### Generate a Cartoon Company Name Source: https://github.com/jeffersongoncalves/laravel-fake-cartoons/blob/master/README.md Generate a random cartoon company name using the Faker provider. ```php fake()->cartoonCompany(); ``` -------------------------------- ### Using $faker->cartoonCompany() in a Laravel Seeder Source: https://github.com/jeffersongoncalves/laravel-fake-cartoons/blob/master/resources/boost/skills/fake-cartoons-development/SKILL.md Use in Laravel seeders to create multiple records with cartoon company names. The $faker parameter is injected by the seeder. ```php use Faker\Generator; class CompanySeeder extends Seeder { public function run(Generator $faker): void { for ($i = 0; $i < 10; $i++) { Company::create([ 'name' => $faker->cartoonCompany(), ]); } } } ``` -------------------------------- ### Testing Auto-Registration of the Provider Source: https://github.com/jeffersongoncalves/laravel-fake-cartoons/blob/master/resources/boost/skills/fake-cartoons-development/SKILL.md Pest test that verifies the provider is auto-registered with Laravel's fake() helper. ```php it('auto-registers the provider with Laravel Faker', function () { $company = fake()->cartoonCompany(); expect($company)->toBeString()->not->toBeEmpty(); }); ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.