mbezhanov/laravel-faker-provider-collection 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

mbezhanov/laravel-faker-provider-collection

最新稳定版本:3.2.0

Composer 安装命令:

composer require mbezhanov/laravel-faker-provider-collection

包简介

A collection of custom Faker providers for your Laravel applications

README 文档

README

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 with Composer:

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

Add the FakerServiceProvider class to your ./bootstrap/providers.php file:

return [
    // other provider definitions
    Bezhanov\Faker\Laravel\FakerServiceProvider::class,
];

At this point, you should be able to use the all the additional faker providers bundled with the library in your Model Factories

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

<?php

namespace Database\Factories;

use Illuminate\Database\Eloquent\Factories\Factory;

class StudentFactory extends Factory
{
    /**
     * Define the model's default state.
     *
     * @return array<string, mixed>
     */
    public function definition(): array
    {
        return [
            'university' => fake()->university,
            'sport' => fake()->sport,
            'team' => fake()->team,
        ];
    }
}

You should be able to do:

/app # php artisan tinker
Psy Shell v0.12.2 (PHP 8.3.4 — cli) by Justin Hileman
> \App\Student::factory(5)->make();
= Illuminate\Database\Eloquent\Collection {#6008
    all: [
      App\Models\Student {#6065
        university: "Ironston Technical College",
        sport: "baseball",
        team: "Minnesota Warlocks",
      },
      App\Models\Student {#5980
        university: "Mallowpond TAFE",
        sport: "hockey",
        team: "New York Oracles",
      },
      App\Models\Student {#6066
        university: "Vertapple College",
        sport: "rugby",
        team: "Delaware Bees",
      },
      App\Models\Student {#6069
        university: "Falconholt University",
        sport: "lacrosse",
        team: "West Virginia Vixens",
      },
      App\Models\Student {#6046
        university: "Flowerlake College",
        sport: "basketball",
        team: "Louisiana Spiders",
      },
    ],
  }
> exit

   INFO  Goodbye.

/app # 

统计信息

  • 总下载量: 68.87k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 22
  • 点击次数: 1
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 21
  • Watchers: 2
  • Forks: 6
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2018-10-04