Skip to content

Commit 7706e3f

Browse files
committed
Migration Discount
1 parent 14e3bbf commit 7706e3f

File tree

2 files changed

+48
-4
lines changed

2 files changed

+48
-4
lines changed

app/Models/Checkout.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ class Checkout extends Model
1414
protected $fillable = [
1515
'user_id',
1616
'camp_id',
17-
'card_number',
18-
'expired',
19-
'cvc',
20-
'is_paid'
17+
'is_paid',
18+
'discount_id',
19+
'discount_percentage',
20+
'total'
2121
];
2222

2323
public function setExpiredAttribute($value)
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
<?php
2+
3+
use Illuminate\Database\Migrations\Migration;
4+
use Illuminate\Database\Schema\Blueprint;
5+
use Illuminate\Support\Facades\Schema;
6+
7+
class AddDiscountIdAndDiscountPercentageAndTotalOnCheckoutsTable extends Migration
8+
{
9+
/**
10+
* Run the migrations.
11+
*
12+
* @return void
13+
*/
14+
public function up()
15+
{
16+
Schema::table('checkouts', function (Blueprint $table) {
17+
$table->foreignId('discount_id')->nullable()->after('camp_id');
18+
$table->unsignedInteger('discount_percentage')->nullable()->after('midtrans_booking_code');
19+
$table->unsignedInteger('total')->default(0)->after('discount_percentage');
20+
$table->foreign('discount_id')->references('id')->on('discounts');
21+
});
22+
}
23+
24+
/**
25+
* Reverse the migrations.
26+
*
27+
* @return void
28+
*/
29+
public function down()
30+
{
31+
Schema::table('checkouts', function (Blueprint $table) {
32+
33+
$table->dropForeign('checkouts_discount_id_foreign');
34+
35+
$table->dropColumn(
36+
[
37+
'discount_id',
38+
'discount_percentage',
39+
'total'
40+
]);
41+
42+
});
43+
}
44+
}

0 commit comments

Comments
 (0)