Files
exchange-2.0/database/migrations/2020_12_01_102314_create_transactions_table.php
T
omair saleh 05401f6bbc large commit
2021-03-11 13:06:40 +08:00

60 lines
2.3 KiB
PHP

<?php
use App\Classes\ValueObjects\Constants\ApprovalStatus;
use App\Classes\ValueObjects\Constants\TransactionType;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateTransactionsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('transactions', function (Blueprint $table) {
$table->id();
$table->foreignId('booking_id')->unsigned();
$table->string('type')->default(TransactionType::PAYMENT);
$table->foreignId('issuer')->unsigned();
$table->foreignId('receiver')->unsigned();
$table->foreignId('recipient_bank_account_id')->unsigned();
$table->string('payment_method')->nullable();
$table->string('payment_reference')->nullable();
$table->string('bill_no')->unique();
$table->decimal('amount', 14, 5)->default(0.00);
$table->decimal('original_amount', 14, 5)->default(0.00);
$table->foreignId('currency_id')->unsigned();
$table->foreignId('original_currency_id')->unsigned();
$table->decimal('currency_rate', 14, 5)->default(0.00);
$table->decimal('tax', 14, 5)->default(0.00);
$table->decimal('service_charge', 14, 5)->default(0.00);
$table->timestamp('expires_on')->nullable();
$table->integer('status')->default(ApprovalStatus::PENDING_SUBMISSION);
$table->softDeletes();
$table->timestamps();
$table->foreign('booking_id')->references('id')->on('bookings');
$table->foreign('currency_id')->references('id')->on('currencies');
$table->foreign('issuer')->references('id')->on('companies');
$table->foreign('receiver')->references('id')->on('companies');
$table->foreign('recipient_bank_account_id')->references('id')->on('banks');
$table->foreign('original_currency_id')->references('id')->on('currencies');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('transaction');
}
}