Skip to content
This repository was archived by the owner on Nov 18, 2022. It is now read-only.
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions app/Models/FlightSim/Network.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?php

namespace App\Models\FlightSim;

use Illuminate\Database\Eloquent\Model;

class Network extends Model
{
protected $fillable = [
'name'
];
}
12 changes: 11 additions & 1 deletion app/Models/Flights/FlightRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class FlightRequest extends Model
* @var array
*/
protected $fillable = [
'departure', 'arrival', 'aircraft_id', 'requestee_id', 'acceptee_id', 'public'
'departure', 'arrival', 'aircraft_id', 'requestee_id', 'acceptee_id', 'public', 'network_id'
];

/**
Expand All @@ -53,6 +53,16 @@ public function plan()
return $this->belongsTo('App\Models\Flights\FlightPlan', 'plan_id');
}

/**
* The network which the flight has.
*
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
*/
public function network()
{
return $this->belongsTo('App\Models\FlightSim\Network');
}

/**
* Checks if a plan exists for the flight
*
Expand Down
1 change: 1 addition & 0 deletions config/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,7 @@
'FlightPlan' => App\Models\Flights\FlightPlan::class,
'Simulator' => App\Models\FlightSim\Simulator::class,
'WeatherEngine' => App\Models\FlightSim\WeatherEngine::class,
'Network' => App\Models\FlightSim\Network::class,
'User' => App\Models\Users\User::class,
],
];
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class AddNetworkToFlightRequestsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('flight_requests', function (Blueprint $table) {
$table->foreignId('network_id')->nullable();
});
}

/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('flight_requests', function (Blueprint $table) {
$table->dropColumn('network_id');
});
}
}
32 changes: 32 additions & 0 deletions database/migrations/2020_12_29_162235_create_networks_table.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateNetworksTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('networks', function (Blueprint $table) {
$table->id();
$table->string('name');
$table->timestamps();
});
}

/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('networks');
}
}
19 changes: 19 additions & 0 deletions database/seeds/NetworkSeeder.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

use Illuminate\Database\Seeder;

class NetworkSeeder extends Seeder
{
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
Network::create(['name' => 'VATSIM']);
Network::create(['name' => 'IVAO']);
Network::create(['name' => 'POSCON']);
Network::create(['name' => 'Multiplayer']);
}
}