Change model

This commit is contained in:
Nabeel Shahzad
2020-10-29 12:06:20 -04:00
parent 5ba65cf2d1
commit aa8cda89d6
2 changed files with 29 additions and 11 deletions

View File

@@ -2,6 +2,7 @@
use App\Contracts\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
class ModifyPirepFares extends Migration
@@ -21,8 +22,11 @@ class ModifyPirepFares extends Migration
Schema::table('pirep_fares', function (Blueprint $table) {
$table->unsignedInteger('fare_id')->change()->nullable()->default(0);
$table->string('code', 50)->unique();
$table->string('code', 50);
$table->string('name', 50);
// count is already there
$table->unsignedDecimal('price')->nullable()->default(0.00);
$table->unsignedDecimal('cost')->nullable()->default(0.00);
$table->unsignedInteger('capacity')->nullable()->default(0);
@@ -33,6 +37,13 @@ class ModifyPirepFares extends Migration
* Some fares might already have been removed deleted so just insert some null/errored
* values for those
*/
$parent_fares = [];
$fares = DB::table('pirep_fares')->get();
foreach ($fares as $fare) {
if (empty($parent_fares[$fare->fare_id])) {
$parent_fares[$fare->fare_id] = DB::table('fares')->where('id', $fare->fare_id)->first();
}
}
}
public function down()