Skip to content

Commit

Permalink
Fix #32: Add Redhill Squawks (#33)
Browse files Browse the repository at this point in the history
  • Loading branch information
AndyTWF authored and CalumTowers committed Feb 25, 2019
1 parent 60f48af commit 51b2a02
Showing 1 changed file with 52 additions and 0 deletions.
52 changes: 52 additions & 0 deletions database/migrations/2019_02_24_221334_add_redhill_squawk.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<?php

use App\Models\Squawks\Range;
use App\Models\Squawks\SquawkRangeOwner;
use App\Models\Squawks\SquawkUnit;
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class AddRedhillSquawk extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
$owner = new SquawkRangeOwner;
$owner->save();

SquawkUnit::create(
[
'unit' => 'EGKR',
'squawk_range_owner_id' => $owner->id,
]
);

Range::create(
[
'squawk_range_owner_id' => $owner->id,
'start' => '3767',
'stop' => '3767',
'rules' => 'A',
'allow_duplicate' => true,
]
);
}

/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
$unit = SquawkUnit::where('unit', '=', 'EGKR')->first();
$unit->delete();
Range::where('squawk_range_owner_id', '=', $unit->squawk_range_owner_id);
SquawkRangeOwner::find($unit->squawk_range_owner_id)->delete();
}
}

0 comments on commit 51b2a02

Please sign in to comment.