hms5232 / webman-factory
Factory for webman framework.
dev-main
2025-07-26 07:57 UTC
Requires
- php: ^8.1
- fakerphp/faker: ^1.21
- illuminate/database: ^12 || ^11 || ^10
- workerman/webman-framework: ^2.1
Requires (Dev)
- squizlabs/php_codesniffer: ^3.13
This package is auto-updated.
Last update: 2025-07-26 07:59:17 UTC
README
Factory for webman framework.
Installation
composer require --dev hms5232/webman-factory
You can remove the --dev
flag as your need.
Usage
Like Laravel factory, but something different and you should do the following additional:
-
The factory file should extend
Hms5232\WebmanFactory\WebmanFactory
:use Hms5232\WebmanFactory\WebmanFactory; class AdminFactory extends WebmanFactory { /** * Define the model's default state. * * @return array */ public function definition() { return [ 'name' => $this->faker->name(), 'email' => $this->faker->unique()->safeEmail(), ]; } }
-
The factory file should specify the model:
use app\model\Admin; use Hms5232\WebmanFactory\WebmanFactory; class AdminFactory extends WebmanFactory { /** * The name of the factory's corresponding model. * * @var class-string<\Illuminate\Database\Eloquent\Model> */ protected $model = Admin::class; }
-
The model file should specify the factory:
// app/model/Admin.php use database\factories\AdminFactory; /** * Create a new factory instance for the model. */ protected static function newFactory() { return AdminFactory::new(); }
-
Currently, the
fake()
is not supported.