Skip to content

Commit

Permalink
Changes for v2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
sohelamin committed Dec 17, 2016
1 parent ed539c1 commit 7b7d75a
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 5 deletions.
27 changes: 27 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,38 @@ Note: You should have configured database for this operation.
php artisan crud:generate Posts --fields="title#string; content#text; category#select#options=technology,tips,health" --view-path=admin --controller-namespace=Admin --route-group=admin
```
#### Crud fields from a JSON file:
```json
{
"fields": [
{
"name": "title",
"type": "string"
},
{
"name": "content",
"type": "text"
},
{
"name": "category",
"type": "select",
"options": ["technology", "tips", "health"]
}
]
}
```

```
php artisan crud:generate Posts --fields_from_file="/path/to/fields.json" --view-path=admin --controller-namespace=Admin --route-group=admin
```

Options:

| Option | Description |
| --- | --- |
| `--fields` | Fields name for the form & migration. e.g. ```--fields="title#string; content#text; category#select#options=technology,tips,health; user_id#integer#unsigned"``` |
| `--fields_from_file` | Fields from a JSON file. e.g. ```--fields_from_file="/path/to/fields.json"``` |
| `--route` | Include Crud route to routes.php? yes or no |
| `--pk` | The name of the primary key |
| `--view-path` | The name of the view path |
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
},
"require-dev": {
"mockery/mockery": "^0.9.6",
"phpunit/phpunit": "^5.6",
"orchestra/testbench": "3.3.x-dev"
"phpunit/phpunit": "^5.7",
"orchestra/testbench": "^3.3"
},
"autoload": {
"psr-4": {
Expand Down
File renamed without changes.
8 changes: 6 additions & 2 deletions tests/CrudGeneratorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ public function testCrudGenerateCommand()
// '--fields' => "title#string; content#text; category#select#options=technology,tips,health",
// ]);
// $this->assertContains('Controller already exists!', $this->consoleOutput());

$this->assertFileNotExists('/path/to/file.php');
}

public function testControllerGenerateCommand()
Expand All @@ -22,6 +20,8 @@ public function testControllerGenerateCommand()
]);

$this->assertContains('Controller created successfully.', $this->consoleOutput());

$this->assertFileExists(app_path('Http/Controllers') . '/CustomersController.php');
}

public function testModelGenerateCommand()
Expand All @@ -32,6 +32,8 @@ public function testModelGenerateCommand()
]);

$this->assertContains('Model created successfully.', $this->consoleOutput());

$this->assertFileExists(app_path() . '/Customer.php');
}

public function testMigrationGenerateCommand()
Expand All @@ -52,5 +54,7 @@ public function testViewGenerateCommand()
]);

$this->assertContains('View created successfully.', $this->consoleOutput());

$this->assertDirectoryExists(config('view.paths')[0] . '/customers');
}
}
3 changes: 2 additions & 1 deletion tests/TestCase.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<?php

abstract class TestCase extends Orchestra\Testbench\TestCase
{
protected $consoleOutput;
Expand All @@ -25,6 +24,8 @@ public function setUp()
parent::setUp();

exec('rm -rf ' . __DIR__ . '/temp/*');
exec('rm -rf ' . app_path() . '/*');
exec('rm -rf ' . database_path('migrations') . '/*');
}

public function tearDown()
Expand Down

0 comments on commit 7b7d75a

Please sign in to comment.