Changed foreign key id field name in person_targets and account_classes from

'io_type' to 'io_type_id'.

Implemented PersonTarget factory.
This commit is contained in:
Lukas Halbritter
2018-09-13 16:04:40 +02:00
parent 47569b0525
commit f394ed773b
5 changed files with 23 additions and 15 deletions
Binary file not shown.
+9 -1
View File
@@ -1,9 +1,17 @@
<?php <?php
use Faker\Generator as Faker; use Faker\Generator as Faker;
use Carbon\Carbon;
use App\IOType;
$factory->define(App\PersonTarget::class, function (Faker $faker) { $factory->define(App\PersonTarget::class, function (Faker $faker) {
return [ return [
// 'io_type_id' => IOType::all('id')->random()->id,
'date' => $faker->dateTimeInInterval('2014-04-01'),
'amount' => $faker->randomFloat(2, 10, 2000),
'reference' => $faker->text(20),
'created_at' => Carbon::now()->format('Y-m-d H:i:s'),
'updated_at' => Carbon::now()->format('Y-m-d H:i:s')
]; ];
}); });
@@ -31,8 +31,8 @@ class CreatePersonTargetsTable extends Migration
// The type of the target. It can be either a payable or a // The type of the target. It can be either a payable or a
// receivable. A payable is of type 'expediture' and a receivable is // receivable. A payable is of type 'expediture' and a receivable is
// of type 'income'. // of type 'income'.
$table->integer('io_type')->unsigned(); $table->integer('io_type_id')->unsigned();
$table->foreign('io_type')->references('id')->on('i_o_types') $table->foreign('io_type_id')->references('id')->on('i_o_types')
->onDelete('no action'); ->onDelete('no action');
// A reference text which describes the target // A reference text which describes the target
@@ -23,8 +23,8 @@ class CreateAccountClassesTable extends Migration
$table->smallInteger('number')->unsigned()->unique(); $table->smallInteger('number')->unsigned()->unique();
// The type of the account class. // The type of the account class.
$table->integer('io_type')->unsigned(); $table->integer('io_type_id')->unsigned();
$table->foreign('io_type')->references('id')->on('i_o_types') $table->foreign('io_type_id')->references('id')->on('i_o_types')
->onDelete('no action'); ->onDelete('no action');
// The scope of the account class. // The scope of the account class.
@@ -15,7 +15,7 @@ class AccountClassesTableSeeder extends Seeder
DB::table('account_classes')->insert([ DB::table('account_classes')->insert([
[ [
'scope_id' => 1, 'scope_id' => 1,
'io_type' => 1, 'io_type_id' => 1,
'number' => 1000, 'number' => 1000,
'name' => 'EINNAHMEN', 'name' => 'EINNAHMEN',
'created_at' => Carbon::now()->format('Y-m-d H:i:s'), 'created_at' => Carbon::now()->format('Y-m-d H:i:s'),
@@ -23,7 +23,7 @@ class AccountClassesTableSeeder extends Seeder
], ],
[ [
'scope_id' => 1, 'scope_id' => 1,
'io_type' => 2, 'io_type_id' => 2,
'number' => 1500, 'number' => 1500,
'name' => 'AUSGABEN', 'name' => 'AUSGABEN',
'created_at' => Carbon::now()->format('Y-m-d H:i:s'), 'created_at' => Carbon::now()->format('Y-m-d H:i:s'),
@@ -31,7 +31,7 @@ class AccountClassesTableSeeder extends Seeder
], ],
[ [
'scope_id' => 2, 'scope_id' => 2,
'io_type' => 1, 'io_type_id' => 1,
'number' => 2000, 'number' => 2000,
'name' => 'EINNAHMEN', 'name' => 'EINNAHMEN',
'created_at' => Carbon::now()->format('Y-m-d H:i:s'), 'created_at' => Carbon::now()->format('Y-m-d H:i:s'),
@@ -39,7 +39,7 @@ class AccountClassesTableSeeder extends Seeder
], ],
[ [
'scope_id' => 2, 'scope_id' => 2,
'io_type' => 2, 'io_type_id' => 2,
'number' => 2500, 'number' => 2500,
'name' => 'AUSGABEN', 'name' => 'AUSGABEN',
'created_at' => Carbon::now()->format('Y-m-d H:i:s'), 'created_at' => Carbon::now()->format('Y-m-d H:i:s'),
@@ -47,7 +47,7 @@ class AccountClassesTableSeeder extends Seeder
], ],
[ [
'scope_id' => 3, 'scope_id' => 3,
'io_type' => 1, 'io_type_id' => 1,
'number' => 3000, 'number' => 3000,
'name' => 'EINNAHMEN', 'name' => 'EINNAHMEN',
'created_at' => Carbon::now()->format('Y-m-d H:i:s'), 'created_at' => Carbon::now()->format('Y-m-d H:i:s'),
@@ -55,7 +55,7 @@ class AccountClassesTableSeeder extends Seeder
], ],
[ [
'scope_id' => 3, 'scope_id' => 3,
'io_type' => 2, 'io_type_id' => 2,
'number' => 3500, 'number' => 3500,
'name' => 'AUSGABEN', 'name' => 'AUSGABEN',
'created_at' => Carbon::now()->format('Y-m-d H:i:s'), 'created_at' => Carbon::now()->format('Y-m-d H:i:s'),
@@ -63,7 +63,7 @@ class AccountClassesTableSeeder extends Seeder
], ],
[ [
'scope_id' => 4, 'scope_id' => 4,
'io_type' => 1, 'io_type_id' => 1,
'number' => 4000, 'number' => 4000,
'name' => 'EINNAHMEN', 'name' => 'EINNAHMEN',
'created_at' => Carbon::now()->format('Y-m-d H:i:s'), 'created_at' => Carbon::now()->format('Y-m-d H:i:s'),
@@ -71,7 +71,7 @@ class AccountClassesTableSeeder extends Seeder
], ],
[ [
'scope_id' => 4, 'scope_id' => 4,
'io_type' => 2, 'io_type_id' => 2,
'number' => 4500, 'number' => 4500,
'name' => 'AUSGABEN', 'name' => 'AUSGABEN',
'created_at' => Carbon::now()->format('Y-m-d H:i:s'), 'created_at' => Carbon::now()->format('Y-m-d H:i:s'),
@@ -79,7 +79,7 @@ class AccountClassesTableSeeder extends Seeder
], ],
[ [
'scope_id' => 5, 'scope_id' => 5,
'io_type' => 1, 'io_type_id' => 1,
'number' => 5000, 'number' => 5000,
'name' => 'EINNAHMEN', 'name' => 'EINNAHMEN',
'created_at' => Carbon::now()->format('Y-m-d H:i:s'), 'created_at' => Carbon::now()->format('Y-m-d H:i:s'),
@@ -87,7 +87,7 @@ class AccountClassesTableSeeder extends Seeder
], ],
[ [
'scope_id' => 5, 'scope_id' => 5,
'io_type' => 2, 'io_type_id' => 2,
'number' => 5500, 'number' => 5500,
'name' => 'AUSGABEN', 'name' => 'AUSGABEN',
'created_at' => Carbon::now()->format('Y-m-d H:i:s'), 'created_at' => Carbon::now()->format('Y-m-d H:i:s'),