First code for #616

This commit is contained in:
James Cole
2017-08-20 12:41:31 +02:00
parent 40639dfa37
commit 7684e966fc
10 changed files with 245 additions and 0 deletions

View File

@@ -0,0 +1,58 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
/**
* Class ChangesForV470
*/
class ChangesForV470 extends Migration
{
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('link_types');
Schema::dropIfExists('journal_types');
}
/**
* Run the migrations.
*
* @SuppressWarnings(PHPMD.ShortMethodName)
* @return void
*/
public function up()
{
if (!Schema::hasTable('link_types')) {
Schema::create(
'link_types', function (Blueprint $table) {
$table->increments('id');
$table->timestamps();
$table->softDeletes();
$table->string('name');
$table->string('outward');
$table->string('inward');
$table->boolean('editable');
}
);
}
if (!Schema::hasTable('journal_links')) {
Schema::create(
'journal_links', function (Blueprint $table) {
$table->increments('id');
$table->integer('link_type_id', false, true);
$table->integer('source_id', false, true);
$table->integer('destination_id', false, true);
$table->text('comment');
$table->integer('sequence', false, true);
}
);
}
}
}

View File

@@ -28,6 +28,7 @@ class DatabaseSeeder extends Seeder
$this->call(TransactionCurrencySeeder::class);
$this->call(TransactionTypeSeeder::class);
$this->call(PermissionSeeder::class);
$this->call(LinkTypeSeeder::class);
}
}

View File

@@ -0,0 +1,57 @@
<?php
/**
* LinkTypeSeeder.php
* Copyright (c) 2017 thegrumpydictator@gmail.com
* This software may be modified and distributed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International License.
*
* See the LICENSE file for details.
*/
declare(strict_types=1);
use FireflyIII\Models\LinkType;
use Illuminate\Database\Seeder;
/**
* Class LinkTypeSeeder
*/
class LinkTypeSeeder extends Seeder
{
/**
*
*/
public function run()
{
$link = new LinkType;
$link->name = 'Related';
$link->inward = 'relates to';
$link->outward = 'is related to';
$link->editable = false;
$link->save();
$link = new LinkType;
$link->name = 'Refund';
$link->inward = 'refunds';
$link->outward = 'is refunded by';
$link->editable = false;
$link->save();
$link = new LinkType;
$link->name = 'PartialRefund';
$link->inward = 'partially refunds';
$link->outward = 'is partially refunded by';
$link->editable = false;
$link->save();
$link = new LinkType;
$link->name = 'Paid';
$link->inward = 'pays for';
$link->outward = 'is paid for by';
$link->editable = false;
$link->save();
}
}