Browse Source

Fixed Migration generator

tags/0.1.0
Nafies Luthfi 8 years ago
parent
commit
39580b0dd1
  1. 14
      src/CrudMake.php
  2. 6
      tests/CrudMakeCommandTest.php

14
src/CrudMake.php

@ -116,7 +116,8 @@ class CrudMake extends Command
private function getMigrationContent()
{
return $this->files->get(__DIR__.'/stubs/migration-create.stub');
$stub = $this->files->get(__DIR__.'/stubs/migration-create.stub');
return $this->replaceMigrationDummyStrings($stub)->replaceClass($stub);
}
public function getIndexViewContent()
@ -183,6 +184,17 @@ class CrudMake extends Command
return $this;
}
protected function replaceMigrationDummyStrings(&$stub)
{
$stub = str_replace(
['DummyTable', 'DummyClass'],
[$this->lowerCasePluralModel, 'Create'.$this->pluralModelName.'Table'],
$stub
);
return $this;
}
protected function replaceClass($stub)
{
$class = str_plural($this->modelName);

6
tests/CrudMakeCommandTest.php

@ -223,7 +223,7 @@ use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class DummyClass extends Migration
class CreateItemsTable extends Migration
{
/**
* Run the migrations.
@ -232,7 +232,7 @@ class DummyClass extends Migration
*/
public function up()
{
Schema::create('DummyTable', function (Blueprint \$table) {
Schema::create('items', function (Blueprint \$table) {
\$table->increments('id');
\$table->string('name', 60);
\$table->string('description');
@ -247,7 +247,7 @@ class DummyClass extends Migration
*/
public function down()
{
Schema::dropIfExists('DummyTable');
Schema::dropIfExists('items');
}
}
";

Loading…
Cancel
Save