@@ -1,6 +1,6 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -$factory->define(App\User::class, function ($faker) { |
|
| 3 | +$factory->define(App\User::class, function($faker) { |
|
| 4 | 4 | return [ |
| 5 | 5 | 'name' => $faker->name, |
| 6 | 6 | 'email' => $faker->email, |
@@ -1,5 +1,5 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -$app->get("/", function () use ($app) { |
|
| 3 | +$app->get("/", function() use ($app) { |
|
| 4 | 4 | return $app->welcome(); |
| 5 | 5 | }); |
@@ -33,7 +33,7 @@ discard block |
||
| 33 | 33 | ->get(); |
| 34 | 34 | |
| 35 | 35 | $file = $this->option('file'); |
| 36 | - if(! $file){ |
|
| 36 | + if (!$file) { |
|
| 37 | 37 | $file = date('Y_m_d_His_') . snake_case($name) . '_table'; |
| 38 | 38 | } |
| 39 | 39 | |
@@ -43,12 +43,12 @@ discard block |
||
| 43 | 43 | protected function getSchema() |
| 44 | 44 | { |
| 45 | 45 | $schema = $this->option('schema'); |
| 46 | - if(! $schema){ |
|
| 46 | + if (!$schema) { |
|
| 47 | 47 | return $this->spaces(12) . "// Schema declaration"; |
| 48 | 48 | } |
| 49 | 49 | |
| 50 | 50 | $items = $schema; |
| 51 | - if( ! $this->option('parsed')){ |
|
| 51 | + if (!$this->option('parsed')) { |
|
| 52 | 52 | $items = $this->getArgumentParser('schema')->parse($schema); |
| 53 | 53 | } |
| 54 | 54 | |
@@ -74,7 +74,7 @@ discard block |
||
| 74 | 74 | $lines[] = $this->spaces(12) . "\$table->{$add}();"; |
| 75 | 75 | } |
| 76 | 76 | |
| 77 | - if(!empty($lines)) |
|
| 77 | + if (!empty($lines)) |
|
| 78 | 78 | return implode(PHP_EOL, $lines); |
| 79 | 79 | else |
| 80 | 80 | return ""; |
@@ -85,7 +85,7 @@ discard block |
||
| 85 | 85 | $name = $parts[0]['name']; |
| 86 | 86 | $parts[1]['args'] = array_merge(["'{$name}'"], $parts[1]['args']); |
| 87 | 87 | unset($parts[0]); |
| 88 | - $parts = array_map(function($part){ |
|
| 88 | + $parts = array_map(function($part) { |
|
| 89 | 89 | return '->' . $part['name'] . '(' . implode(', ', $part['args']) . ')'; |
| 90 | 90 | }, $parts); |
| 91 | 91 | return $this->spaces(12) . "\$table" . implode('', $parts) . ';'; |
@@ -94,12 +94,12 @@ discard block |
||
| 94 | 94 | protected function getConstraints() |
| 95 | 95 | { |
| 96 | 96 | $keys = $this->option('keys'); |
| 97 | - if(! $keys){ |
|
| 97 | + if (!$keys) { |
|
| 98 | 98 | return $this->spaces(12) . "// Constraints declaration"; |
| 99 | 99 | } |
| 100 | 100 | |
| 101 | 101 | $items = $keys; |
| 102 | - if(! $this->option('parsed')){ |
|
| 102 | + if (!$this->option('parsed')) { |
|
| 103 | 103 | $items = $this->getArgumentParser('foreign-keys')->parse($keys); |
| 104 | 104 | } |
| 105 | 105 | |
@@ -113,10 +113,10 @@ discard block |
||
| 113 | 113 | |
| 114 | 114 | protected function getConstraintDeclaration($key) |
| 115 | 115 | { |
| 116 | - if(! $key['column']){ |
|
| 116 | + if (!$key['column']) { |
|
| 117 | 117 | $key['column'] = 'id'; |
| 118 | 118 | } |
| 119 | - if(! $key['table']){ |
|
| 119 | + if (!$key['table']) { |
|
| 120 | 120 | $key['table'] = str_plural(substr($key['name'], 0, strlen($key['name']) - 3)); |
| 121 | 121 | } |
| 122 | 122 | |
@@ -131,7 +131,7 @@ discard block |
||
| 131 | 131 | ]) |
| 132 | 132 | ->get(); |
| 133 | 133 | |
| 134 | - if($key['on_delete']){ |
|
| 134 | + if ($key['on_delete']) { |
|
| 135 | 135 | $constraint .= $this->getTemplate('migration/on-constraint') |
| 136 | 136 | ->with([ |
| 137 | 137 | 'event' => 'Delete', |
@@ -140,7 +140,7 @@ discard block |
||
| 140 | 140 | ->get(); |
| 141 | 141 | } |
| 142 | 142 | |
| 143 | - if($key['on_update']){ |
|
| 143 | + if ($key['on_update']) { |
|
| 144 | 144 | $constraint .= $this->getTemplate('migration/on-constraint') |
| 145 | 145 | ->with([ |
| 146 | 146 | 'event' => 'Update', |
@@ -74,10 +74,11 @@ |
||
| 74 | 74 | $lines[] = $this->spaces(12) . "\$table->{$add}();"; |
| 75 | 75 | } |
| 76 | 76 | |
| 77 | - if(!empty($lines)) |
|
| 78 | - return implode(PHP_EOL, $lines); |
|
| 79 | - else |
|
| 80 | - return ""; |
|
| 77 | + if(!empty($lines)) { |
|
| 78 | + return implode(PHP_EOL, $lines); |
|
| 79 | + } else { |
|
| 80 | + return ""; |
|
| 81 | + } |
|
| 81 | 82 | } |
| 82 | 83 | |
| 83 | 84 | protected function getFieldDeclaration($parts) |
@@ -14,10 +14,10 @@ discard block |
||
| 14 | 14 | $I->seeInThisFile('protected $fillable = ["name", "descr", "due", "project_id", "user_id"];'); |
| 15 | 15 | $I->seeInThisFile('protected $dates = ["due"];'); |
| 16 | 16 | $I->seeInThisFile( |
| 17 | -"public static \$rules = [\n". |
|
| 17 | +"public static \$rules = [\n" . |
|
| 18 | 18 | " \"name\" => \"requied\"," . PHP_EOL . |
| 19 | 19 | " \"project_id\" => \"required|numeric\"," . PHP_EOL . |
| 20 | -" \"user_id\" => \"required|numeric\",\n". |
|
| 20 | +" \"user_id\" => \"required|numeric\",\n" . |
|
| 21 | 21 | " ];"); |
| 22 | 22 | $I->seeInThisFile( |
| 23 | 23 | ' public function tags() |
@@ -47,15 +47,15 @@ discard block |
||
| 47 | 47 | $I->openFile('./database/migrations/create_task_categories.php'); |
| 48 | 48 | |
| 49 | 49 | $I->seeInThisFile('class CreateTaskCategoriesTable extends Migration'); |
| 50 | -$I->seeInThisFile("Schema::create('task_categories', function(Blueprint \$table) {\n". |
|
| 51 | -" \$table->increments('id');\n". |
|
| 50 | +$I->seeInThisFile("Schema::create('task_categories', function(Blueprint \$table) {\n" . |
|
| 51 | +" \$table->increments('id');\n" . |
|
| 52 | 52 | " \$table->string('name')->unique();" . PHP_EOL . |
| 53 | 53 | " \$table->text('descr')->nullable();" . PHP_EOL . |
| 54 | 54 | " \$table->timestamp('due');" . PHP_EOL . |
| 55 | -" \$table->integer('project_id')->unsigned();" . PHP_EOL. |
|
| 55 | +" \$table->integer('project_id')->unsigned();" . PHP_EOL . |
|
| 56 | 56 | " \$table->integer('user_id')->unsigned();" . PHP_EOL . |
| 57 | 57 | " \$table->foreign('project_id')->references('id')->on('projects');" . PHP_EOL . |
| 58 | -" \$table->foreign('user_id')->references('id')->on('users');". PHP_EOL . |
|
| 58 | +" \$table->foreign('user_id')->references('id')->on('users');" . PHP_EOL . |
|
| 59 | 59 | " \$table->timestamps();"); |
| 60 | 60 | |
| 61 | 61 | $I->deleteFile('./database/migrations/create_task_categories.php'); |
@@ -104,8 +104,8 @@ |
||
| 104 | 104 | $I->seeInShellOutput('tasks migration generated'); |
| 105 | 105 | $I->seeFileFound('./database/migrations/create_tasks.php'); |
| 106 | 106 | $I->openFile('./database/migrations/create_tasks.php'); |
| 107 | -$I->seeInThisFile($spaces(12)."\$table->foreign('category_type_id')->references('id')->on('category_types');"); |
|
| 108 | -$I->seeInThisFile($spaces(12)."\$table->foreign('user_id')->references('identifier')->on('members')->onDelete('cascade');"); |
|
| 107 | +$I->seeInThisFile($spaces(12) . "\$table->foreign('category_type_id')->references('id')->on('category_types');"); |
|
| 108 | +$I->seeInThisFile($spaces(12) . "\$table->foreign('user_id')->references('identifier')->on('members')->onDelete('cascade');"); |
|
| 109 | 109 | $I->deleteFile('./database/migrations/create_tasks.php'); |
| 110 | 110 | |
| 111 | 111 | $I->wantTo('generate a migration with additional columns'); |