Create model and migration for imports
ADD
app/Import.php
+<?php
+
+namespace App;
+
+use Illuminate\Database\Eloquent\Model;
+
+class Import extends Model {
+ //
+}

MODIFY
app/Space.php
app/Space.php
@@ -30,4 +30,8 @@ class Space extends Model {
public function recurrings() {
return $this->hasMany(Recurring::class);
}
+
+ public function imports() {
+ return $this->hasMany(Import::class);
+ }
}

ADD
database/migrations/2018_10_14_122724_create_imports_table.php
+<?php
+
+use Illuminate\Support\Facades\Schema;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Database\Migrations\Migration;
+
+class CreateImportsTable extends Migration {
+ public function up() {
+ Schema::create('imports', function (Blueprint $table) {
+ $table->increments('id');
+ $table->unsignedInteger('space_id');
+ $table->string('name');
+ $table->string('type');
+ $table->string('file');
+ $table->integer('status')->default(0);
+ $table->timestamps();
+
+ // FKs
+ $table->foreign('space_id')->references('id')->on('spaces');
+ });
+ }
+
+ public function down() {
+ Schema::table('imports', function ($table) {
+ $table->dropForeign('imports_space_id_foreign');
+ });
+
+ Schema::dropIfExists('imports');
+ }
+}

Create model and migration for imports