Enabled setting faker field

This commit is contained in:
Hillel Coren 2017-04-09 10:34:13 +03:00
parent 1bd0ef12e4
commit 43fc67011e

View File

@ -21,7 +21,7 @@ class CreateLuisData extends Command
/** /**
* @var string * @var string
*/ */
protected $signature = 'ninja:create-luis-data'; protected $signature = 'ninja:create-luis-data {faker_field=name}';
/** /**
* CreateLuisData constructor. * CreateLuisData constructor.
@ -39,6 +39,8 @@ class CreateLuisData extends Command
*/ */
public function fire() public function fire()
{ {
$this->fakerField = $this->argument('faker_field');
$intents = []; $intents = [];
$entityTypes = [ $entityTypes = [
ENTITY_INVOICE, ENTITY_INVOICE,
@ -87,7 +89,7 @@ class CreateLuisData extends Command
$entityType => 'EntityType', $entityType => 'EntityType',
]); ]);
if ($entityType != ENTITY_CLIENT) { if ($entityType != ENTITY_CLIENT) {
$client = $this->faker->firstName; $client = $this->faker->{$this->fakerField};
$phrase .= " for {$client}"; $phrase .= " for {$client}";
$intents[] = $this->createIntent('CreateEntity', $phrase, [ $intents[] = $this->createIntent('CreateEntity', $phrase, [
$entityType => 'EntityType', $entityType => 'EntityType',
@ -104,13 +106,13 @@ class CreateLuisData extends Command
$intents = []; $intents = [];
if (in_array($entityType, [ENTITY_CLIENT, ENTITY_INVOICE, ENTITY_QUOTE])) { if (in_array($entityType, [ENTITY_CLIENT, ENTITY_INVOICE, ENTITY_QUOTE])) {
$name = $entityType === ENTITY_CLIENT ? $this->faker->firstName : $this->faker->randomNumber(4); $name = $entityType === ENTITY_CLIENT ? $this->faker->{$this->fakerField} : $this->faker->randomNumber(4);
$intents[] = $this->createIntent('FindEntity', "find {$entityType} {$name}", [ $intents[] = $this->createIntent('FindEntity', "find {$entityType} {$name}", [
$entityType => 'EntityType', $entityType => 'EntityType',
$name => 'Name', $name => 'Name',
]); ]);
if ($entityType === ENTITY_CLIENT) { if ($entityType === ENTITY_CLIENT) {
$name = $this->faker->firstName; $name = $this->faker->{$this->fakerField};
$intents[] = $this->createIntent('FindEntity', "find {$name}", [ $intents[] = $this->createIntent('FindEntity', "find {$name}", [
$name => 'Name', $name => 'Name',
]); ]);
@ -143,7 +145,7 @@ class CreateLuisData extends Command
]); ]);
if ($entityType != ENTITY_CLIENT) { if ($entityType != ENTITY_CLIENT) {
$client = $this->faker->firstName; $client = $this->faker->{$this->fakerField};
$intents[] = $this->createIntent('ListEntity', "list {$entityTypePlural} for {$client}", [ $intents[] = $this->createIntent('ListEntity', "list {$entityTypePlural} for {$client}", [
$entityTypePlural => 'EntityType', $entityTypePlural => 'EntityType',
$client => 'Name', $client => 'Name',