diff --git a/app/Models/Zone.php b/app/Models/Zone.php index cb47e12..7d1090b 100644 --- a/app/Models/Zone.php +++ b/app/Models/Zone.php @@ -4,7 +4,19 @@ namespace App\Models; use Illuminate\Database\Eloquent\Model; +use App\Traits\ScopeActive; + class Zone extends Model { - protected $fillable = ['id']; + use ScopeActive; + + /* SCOPES */ + + /** + * Only query active records + */ + public function scopePublic() + { + return $this->where('public',TRUE); + } } \ No newline at end of file diff --git a/app/Traits/ScopeActive.php b/app/Traits/ScopeActive.php new file mode 100644 index 0000000..3d43601 --- /dev/null +++ b/app/Traits/ScopeActive.php @@ -0,0 +1,17 @@ +where('active',TRUE); + } +} diff --git a/database/migrations/2014_10_12_000000_create_users_table.php b/database/migrations/2014_10_12_000000_create_users_table.php index 16a6108..e2dc6f2 100644 --- a/database/migrations/2014_10_12_000000_create_users_table.php +++ b/database/migrations/2014_10_12_000000_create_users_table.php @@ -6,31 +6,31 @@ use Illuminate\Database\Migrations\Migration; class CreateUsersTable extends Migration { - /** - * Run the migrations. - * - * @return void - */ - public function up() - { - Schema::create('users', function (Blueprint $table) { - $table->increments('id'); - $table->string('name'); - $table->string('email')->unique(); - $table->timestamp('email_verified_at')->nullable(); - $table->string('password'); - $table->rememberToken(); - $table->timestamps(); - }); - } + /** + * Run the migrations. + * + * @return void + */ + public function up() + { + Schema::create('users', function (Blueprint $table) { + $table->increments('id'); + $table->string('name'); + $table->string('email')->unique(); + $table->timestamp('email_verified_at')->nullable(); + $table->string('password'); + $table->rememberToken(); + $table->timestamps(); + }); + } - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::dropIfExists('users'); - } + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('users'); + } } diff --git a/database/migrations/2014_10_12_100000_create_password_resets_table.php b/database/migrations/2014_10_12_100000_create_password_resets_table.php index 0d5cb84..16d8233 100644 --- a/database/migrations/2014_10_12_100000_create_password_resets_table.php +++ b/database/migrations/2014_10_12_100000_create_password_resets_table.php @@ -6,27 +6,27 @@ use Illuminate\Database\Migrations\Migration; class CreatePasswordResetsTable extends Migration { - /** - * Run the migrations. - * - * @return void - */ - public function up() - { - Schema::create('password_resets', function (Blueprint $table) { - $table->string('email')->index(); - $table->string('token'); - $table->timestamp('created_at')->nullable(); - }); - } + /** + * Run the migrations. + * + * @return void + */ + public function up() + { + Schema::create('password_resets', function (Blueprint $table) { + $table->string('email')->index(); + $table->string('token'); + $table->timestamp('created_at')->nullable(); + }); + } - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::dropIfExists('password_resets'); - } + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('password_resets'); + } } diff --git a/database/migrations/2019_04_16_090345_create_domains.php b/database/migrations/2019_04_16_090345_create_domains.php new file mode 100644 index 0000000..f62166d --- /dev/null +++ b/database/migrations/2019_04_16_090345_create_domains.php @@ -0,0 +1,33 @@ +id(); + $table->timestamps(); + $table->string('name',8)->unique(); + $table->string('dnsdomain')->nullable(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('domains'); + } +} diff --git a/database/migrations/2019_04_16_105253_create_zones.php b/database/migrations/2019_04_16_105253_create_zones.php index 9e503f8..2e29215 100644 --- a/database/migrations/2019_04_16_105253_create_zones.php +++ b/database/migrations/2019_04_16_105253_create_zones.php @@ -6,36 +6,44 @@ use Illuminate\Database\Migrations\Migration; class CreateZones extends Migration { - /** - * Run the migrations. - * - * @return void - */ - public function up() - { - Schema::create('zones', function (Blueprint $table) { - $table->integer('id')->primary(); - $table->timestamps(); - $table->binary('zt_id',10)->nullable(); - $table->binary('ztnet',6)->nullable(); - $table->ipAddress('ipv4')->nullable(); - $table->integer('ipv4_mask')->nullable(); - $table->ipAddress('ipv6')->nullable(); - $table->integer('ipv6_mask')->nullable(); + /** + * Run the migrations. + * + * @return void + */ + public function up() + { + Schema::create('zones', function (Blueprint $table) { + $table->integer('id')->primary(); + $table->timestamps(); - $table->unique('zt_id'); - $table->foreign('zt_id')->references('id')->on('zt'); - }); + $table->integer('zone_id'); + $table->string('description')->nullable(); + $table->boolean('active')->default(TRUE); + $table->boolean('public')->default(TRUE); - } + $table->ipAddress('ipv4')->nullable(); + $table->integer('ipv4_mask')->nullable(); - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::dropIfExists('zones'); - } + $table->ipAddress('ipv6')->nullable(); + $table->integer('ipv6_mask')->nullable(); + + $table->integer('domain_id')->nullable()->unique(); + $table->foreign('domain_id')->references('id')->on('domains'); + + $table->binary('zt_id',10)->nullable()->unique(); + $table->foreign('zt_id')->references('id')->on('zt'); + }); + + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('zones'); + } } diff --git a/database/migrations/2019_04_16_105254_create_nodes.php b/database/migrations/2019_04_16_105254_create_nodes.php index c46b445..82b1c50 100644 --- a/database/migrations/2019_04_16_105254_create_nodes.php +++ b/database/migrations/2019_04_16_105254_create_nodes.php @@ -28,8 +28,9 @@ class CreateNodes extends Migration $table->string('system'); $table->string('sysop'); $table->string('location'); - $table->integer('baud'); + $table->integer('baud')->default('0'); $table->string('phone')->nullable(); + $table->binary('zt',10)->nullable(); $table->unique(['zone_id','host_id','node_id','point_id']); diff --git a/database/migrations/2019_04_26_112227_create_echomail.php b/database/migrations/2019_04_26_112227_create_echomail.php index df4b164..aeeaa50 100644 --- a/database/migrations/2019_04_26_112227_create_echomail.php +++ b/database/migrations/2019_04_26_112227_create_echomail.php @@ -6,51 +6,51 @@ use Illuminate\Database\Migrations\Migration; class CreateEchomail extends Migration { - /** - * Run the migrations. - * - * @return void - */ - public function up() - { - Schema::create('echomails', function (Blueprint $table) { - $table->increments('id'); - $table->timestamps(); - $table->integer('pkt_from'); - $table->integer('pkt_to'); - $table->datetime('pkt_date'); - $table->string('pkt'); - $table->string('flags'); - $table->integer('cost'); - $table->string('from_user'); - $table->integer('from_ftn'); - $table->string('to_user'); - $table->string('subject'); - $table->datetime('date'); - $table->string('tz')->nullable(); - $table->string('area'); - $table->string('msgid')->nullable(); - $table->string('replyid')->nullable(); - $table->text('message'); - $table->string('origin'); - $table->text('original')->nullable(); + /** + * Run the migrations. + * + * @return void + */ + public function up() + { + Schema::create('echomails', function (Blueprint $table) { + $table->increments('id'); + $table->timestamps(); + $table->integer('pkt_from'); + $table->integer('pkt_to'); + $table->datetime('pkt_date'); + $table->string('pkt'); + $table->string('flags'); + $table->integer('cost'); + $table->string('from_user'); + $table->integer('from_ftn'); + $table->string('to_user'); + $table->string('subject'); + $table->datetime('date'); + $table->string('tz')->nullable(); + $table->string('area'); + $table->string('msgid')->nullable(); + $table->string('replyid')->nullable(); + $table->text('message'); + $table->string('origin'); + $table->text('original')->nullable(); - $table->index('pkt_from'); - $table->index('pkt_to'); - $table->index('from_ftn'); - $table->foreign('pkt_from')->references('id')->on('nodes'); - $table->foreign('pkt_to')->references('id')->on('nodes'); - $table->foreign('from_ftn')->references('id')->on('nodes'); - }); - } + $table->index('pkt_from'); + $table->index('pkt_to'); + $table->index('from_ftn'); + $table->foreign('pkt_from')->references('id')->on('nodes'); + $table->foreign('pkt_to')->references('id')->on('nodes'); + $table->foreign('from_ftn')->references('id')->on('nodes'); + }); + } - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::dropIfExists('echomails'); - } + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('echomails'); + } } diff --git a/database/migrations/2019_04_26_112228_create_echomail_tables.php b/database/migrations/2019_04_26_112228_create_echomail_tables.php index 7c17b8f..ed061b5 100644 --- a/database/migrations/2019_04_26_112228_create_echomail_tables.php +++ b/database/migrations/2019_04_26_112228_create_echomail_tables.php @@ -6,57 +6,57 @@ use Illuminate\Database\Migrations\Migration; class CreateEchomailTables extends Migration { - /** - * Run the migrations. - * - * @return void - */ - public function up() - { - Schema::create('echomail_kludge', function (Blueprint $table) { - $table->integer('echomail_id'); - $table->string('kludge_id')->nullable(); - $table->json('value'); + /** + * Run the migrations. + * + * @return void + */ + public function up() + { + Schema::create('echomail_kludge', function (Blueprint $table) { + $table->integer('echomail_id'); + $table->string('kludge_id')->nullable(); + $table->json('value'); - $table->index('echomail_id'); - $table->foreign('echomail_id')->references('id')->on('echomails'); - }); + $table->index('echomail_id'); + $table->foreign('echomail_id')->references('id')->on('echomails'); + }); - Schema::create('echomail_seenby', function (Blueprint $table) { - $table->integer('echomail_id'); - $table->integer('node_id'); + Schema::create('echomail_seenby', function (Blueprint $table) { + $table->integer('echomail_id'); + $table->integer('node_id'); - $table->unique(['echomail_id','node_id']); + $table->unique(['echomail_id','node_id']); - $table->index('echomail_id'); - $table->foreign('echomail_id')->references('id')->on('echomails'); - $table->index('node_id'); - $table->foreign('node_id')->references('id')->on('nodes'); - }); + $table->index('echomail_id'); + $table->foreign('echomail_id')->references('id')->on('echomails'); + $table->index('node_id'); + $table->foreign('node_id')->references('id')->on('nodes'); + }); - Schema::create('echomail_path', function (Blueprint $table) { - $table->integer('echomail_id'); - $table->integer('node_id'); - $table->integer('sequence'); + Schema::create('echomail_path', function (Blueprint $table) { + $table->integer('echomail_id'); + $table->integer('node_id'); + $table->integer('sequence'); - $table->unique(['echomail_id','sequence']); + $table->unique(['echomail_id','sequence']); - $table->index('echomail_id'); - $table->foreign('echomail_id')->references('id')->on('echomails'); - $table->index('node_id'); - $table->foreign('node_id')->references('id')->on('nodes'); - }); - } + $table->index('echomail_id'); + $table->foreign('echomail_id')->references('id')->on('echomails'); + $table->index('node_id'); + $table->foreign('node_id')->references('id')->on('nodes'); + }); + } - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::dropIfExists('echomail_path'); - Schema::dropIfExists('echomail_seenby'); - Schema::dropIfExists('echomail_kludge'); - } + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('echomail_path'); + Schema::dropIfExists('echomail_seenby'); + Schema::dropIfExists('echomail_kludge'); + } } diff --git a/database/migrations/2019_04_26_112307_create_netmail.php b/database/migrations/2019_04_26_112307_create_netmail.php index 46c4a05..74fcb41 100644 --- a/database/migrations/2019_04_26_112307_create_netmail.php +++ b/database/migrations/2019_04_26_112307_create_netmail.php @@ -6,55 +6,55 @@ use Illuminate\Database\Migrations\Migration; class CreateNetmail extends Migration { - /** - * Run the migrations. - * - * @return void - */ - public function up() - { - Schema::create('netmails', function (Blueprint $table) { - $table->increments('id'); - $table->timestamps(); + /** + * Run the migrations. + * + * @return void + */ + public function up() + { + Schema::create('netmails', function (Blueprint $table) { + $table->increments('id'); + $table->timestamps(); - $table->integer('pkt_from'); - $table->integer('pkt_to'); - $table->datetime('pkt_date'); - $table->string('pkt'); + $table->integer('pkt_from'); + $table->integer('pkt_to'); + $table->datetime('pkt_date'); + $table->string('pkt'); - $table->string('flags'); - $table->integer('cost'); - $table->string('from_user'); - $table->integer('from_ftn'); - $table->string('to_user'); - $table->integer('to_ftn'); - $table->string('subject'); - $table->datetime('date'); - $table->string('tz')->nullable(); - $table->string('msgid')->nullable(); - $table->string('replyid')->nullable(); - $table->text('message'); - $table->string('origin'); - $table->text('original')->nullable(); + $table->string('flags'); + $table->integer('cost'); + $table->string('from_user'); + $table->integer('from_ftn'); + $table->string('to_user'); + $table->integer('to_ftn'); + $table->string('subject'); + $table->datetime('date'); + $table->string('tz')->nullable(); + $table->string('msgid')->nullable(); + $table->string('replyid')->nullable(); + $table->text('message'); + $table->string('origin'); + $table->text('original')->nullable(); - $table->index('pkt_from'); - $table->index('pkt_to'); - $table->index('from_ftn'); - $table->index('to_ftn'); - $table->foreign('pkt_from')->references('id')->on('nodes'); - $table->foreign('pkt_to')->references('id')->on('nodes'); - $table->foreign('from_ftn')->references('id')->on('nodes'); - $table->foreign('to_ftn')->references('id')->on('nodes'); - }); - } + $table->index('pkt_from'); + $table->index('pkt_to'); + $table->index('from_ftn'); + $table->index('to_ftn'); + $table->foreign('pkt_from')->references('id')->on('nodes'); + $table->foreign('pkt_to')->references('id')->on('nodes'); + $table->foreign('from_ftn')->references('id')->on('nodes'); + $table->foreign('to_ftn')->references('id')->on('nodes'); + }); + } - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::dropIfExists('netmails'); - } + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('netmails'); + } } diff --git a/database/migrations/2019_04_26_113128_create_netmail_tables.php b/database/migrations/2019_04_26_113128_create_netmail_tables.php index f280f76..4c0199b 100644 --- a/database/migrations/2019_04_26_113128_create_netmail_tables.php +++ b/database/migrations/2019_04_26_113128_create_netmail_tables.php @@ -6,45 +6,45 @@ use Illuminate\Database\Migrations\Migration; class CreateNetmailTables extends Migration { - /** - * Run the migrations. - * - * @return void - */ - public function up() - { - Schema::create('kludge_netmail', function (Blueprint $table) { - $table->integer('netmail_id'); - $table->string('kludge_id')->nullable(); - $table->json('value'); + /** + * Run the migrations. + * + * @return void + */ + public function up() + { + Schema::create('kludge_netmail', function (Blueprint $table) { + $table->integer('netmail_id'); + $table->string('kludge_id')->nullable(); + $table->json('value'); - $table->index('netmail_id'); - $table->foreign('netmail_id')->references('id')->on('netmails'); - }); + $table->index('netmail_id'); + $table->foreign('netmail_id')->references('id')->on('netmails'); + }); - Schema::create('netmail_path', function (Blueprint $table) { - $table->integer('netmail_id'); - $table->integer('node_id'); - $table->integer('sequence'); - $table->json('value'); + Schema::create('netmail_path', function (Blueprint $table) { + $table->integer('netmail_id'); + $table->integer('node_id'); + $table->integer('sequence'); + $table->json('value'); - $table->unique(['netmail_id','sequence']); + $table->unique(['netmail_id','sequence']); - $table->index('netmail_id'); - $table->foreign('netmail_id')->references('id')->on('netmails'); - $table->index('node_id'); - $table->foreign('node_id')->references('id')->on('nodes'); - }); - } + $table->index('netmail_id'); + $table->foreign('netmail_id')->references('id')->on('netmails'); + $table->index('node_id'); + $table->foreign('node_id')->references('id')->on('nodes'); + }); + } - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::dropIfExists('netmail_path'); - Schema::dropIfExists('kludge_netmail'); - } + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('netmail_path'); + Schema::dropIfExists('kludge_netmail'); + } } diff --git a/database/migrations/2021_05_03_104554_create_setup.php b/database/migrations/2021_05_03_104554_create_setup.php new file mode 100644 index 0000000..71405ac --- /dev/null +++ b/database/migrations/2021_05_03_104554_create_setup.php @@ -0,0 +1,41 @@ +id(); + $table->timestamps(); + + $table->integer('opt_md'); + }); + + Schema::create('node_setup', function (Blueprint $table) { + $table->integer('node_id'); + $table->foreign('node_id')->references('id')->on('nodes'); + $table->integer('setup_id'); + $table->foreign('setup_id')->references('id')->on('setups'); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('node_setup'); + Schema::dropIfExists('setups'); + } +} diff --git a/database/seeds/InitialSetupSeeder.php b/database/seeds/InitialSetupSeeder.php new file mode 100644 index 0000000..d4c809a --- /dev/null +++ b/database/seeds/InitialSetupSeeder.php @@ -0,0 +1,69 @@ +insert([ + 'name'=>'BINKP', + 'port'=>24554, + 'active'=>TRUE, + ]); + DB::table('protocols')->insert([ + 'name'=>'EMSI', + 'port'=>60179, + 'active'=>TRUE, + ]); + DB::table('software')->insert([ + 'name'=>'Custom', + 'active'=>TRUE, + ]); + + DB::table('domains')->insert([ + 'name' => 'private', + ]); + + DB::table('zones')->insert([ + 'zone_id'=>'10', + 'domain_id'=>1, + 'public'=>TRUE, + 'active'=>TRUE, + 'name'=>'private', + 'description'=>'PrivateNet: Internal Testing Network' + ]); + + DB::table('nodes')->insert([ + 'zone_id'=>'1', + 'host_id'=>'999', + 'node_id'=>'999', + 'is_host'=>TRUE, + 'active'=>TRUE, + 'system'=>'FTN Clearing House Dev', + 'sysop'=>'Deon George', + 'location'=>'Parkdale, AUS', + 'email'=>'deon@leenooks.net', + 'address'=>'fidohub.leenooks.net', + 'port'=>24554, + 'protocol_id'=>1, + 'software_id'=>1, + ]); + + DB::table('setups')->insert([ + 'opt_md'=>'1', + ]); + + DB::table('setup')->insert([ + 'node_id' => '1', + ]); + } +}