-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
60f48af
commit 51b2a02
Showing
1 changed file
with
52 additions
and
0 deletions.
There are no files selected for viewing
52 changes: 52 additions & 0 deletions
52
database/migrations/2019_02_24_221334_add_redhill_squawk.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
} |