This commit is contained in:
CheeSiong
2020-12-28 21:41:42 +08:00
parent ab499f9ceb
commit 3b333ecfba
5 changed files with 102 additions and 0 deletions
@@ -0,0 +1,9 @@
<?php
namespace App\Classes\ValueObjects\Constants;
final class CurrencyType {
public const CASH = 1;
public const CHEQUE = 2;
public const PA = 3;
}
+10
View File
@@ -0,0 +1,10 @@
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class CurrencyRate extends Model
{
//
}
+10
View File
@@ -0,0 +1,10 @@
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class CurrencyRateLog extends Model
{
//
}
@@ -0,0 +1,37 @@
<?php
use App\Classes\ValueObjects\Constants\CurrencyType;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateCurrencyRatesTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('currency_rates', function (Blueprint $table) {
$table->id();
$table->bigInteger('currency_id')->unsigned()->nullable();
$table->foreign('currency_id')->references('id')->on('currencies')->onDelete('cascade');
$table->decimal('selling', 20, 5)->nullable();
$table->integer('currency_type')->default(CurrencyType::CASH);
$table->timestamps();
$table->softDeletes();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('currency_rates');
}
}
@@ -0,0 +1,36 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateCurrencyRateLogsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('currency_rate_logs', function (Blueprint $table) {
$table->id();
$table->bigInteger('currency_rate_id')->unsigned()->nullable();
$table->foreign('currency_rate_id')->references('id')->on('currency_rates')->onDelete('cascade');
$table->decimal('selling', 20, 5)->nullable();
$table->bigInteger('created_by')->unsigned()->nullable();
$table->foreign('created_by')->references('id')->on('users')->onDelete('cascade');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('currency_rate_logs');
}
}