From 42721e95726559b4a601240bb5b0fe4e5d755b2a Mon Sep 17 00:00:00 2001 From: Igor Scheller Date: Wed, 27 Nov 2019 23:43:21 +0100 Subject: Added Schedule parsing and replaced old Fahrplan importer Resolves #553 (Change Frab Import from xCal to XML) Resolves #538 (Feature Request: Multi Frab Import) --- db/migrations/Reference.php | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) (limited to 'db/migrations/Reference.php') diff --git a/db/migrations/Reference.php b/db/migrations/Reference.php index 49a1f9ea..d0550686 100644 --- a/db/migrations/Reference.php +++ b/db/migrations/Reference.php @@ -4,6 +4,7 @@ namespace Engelsystem\Migrations; use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Schema\ColumnDefinition; +use Illuminate\Support\Str; trait Reference { @@ -11,20 +12,25 @@ trait Reference * @param Blueprint $table * @param bool $setPrimary */ - protected function referencesUser(Blueprint $table, $setPrimary = false) + protected function referencesUser(Blueprint $table, bool $setPrimary = false) { - $this->references($table, 'users', 'user_id', $setPrimary); + $this->references($table, 'users', null, $setPrimary); } /** - * @param Blueprint $table - * @param string $targetTable - * @param string $fromColumn - * @param bool $setPrimary + * @param Blueprint $table + * @param string $targetTable + * @param string|null $fromColumn + * @param bool $setPrimary * @return ColumnDefinition */ - protected function references(Blueprint $table, $targetTable, $fromColumn, $setPrimary = false): ColumnDefinition - { + protected function references( + Blueprint $table, + string $targetTable, + ?string $fromColumn = null, + bool $setPrimary = false + ): ColumnDefinition { + $fromColumn = $fromColumn ?? Str::singular($targetTable) . '_id'; $col = $table->unsignedInteger($fromColumn); if ($setPrimary) { -- cgit v1.3.1