Skip to content

Commit

Permalink
wallet add txn
Browse files Browse the repository at this point in the history
  • Loading branch information
krutyosila committed Nov 24, 2020
1 parent 096e227 commit dd81d25
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Models/WalletTransaction.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
class WalletTransaction extends Model
{
protected $fillable = [
'wallet_id', 'type', 'intermediary', 'amount', 'confirmed', 'meta'
'wallet_id', 'txn', 'type', 'intermediary', 'amount', 'confirmed', 'meta'
];

protected $casts = [
Expand Down
18 changes: 18 additions & 0 deletions src/Types/WalletTransactionType.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

namespace Krutyosila\Wallet\Types;

use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Str;
use Krutyosila\Wallet\Models\Wallet;

class WalletTransactionType
Expand All @@ -12,6 +14,7 @@ class WalletTransactionType
public $amount;
public $meta;
public $confirmed;
public $txn;

/**
* @param Wallet $wallet
Expand Down Expand Up @@ -109,6 +112,21 @@ public function setConfirmed($confirmed)
$this->confirmed = $confirmed;
}

/**
* @return mixed
*/
public function getTxn()
{
return $this->txn;
}

/**
* @param mixed $txn
*/
public function setTxn($txn)
{
$this->txn = Str::random(32);
}
/**
* @return array
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class UpdateWalletTransactionTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('wallet_transactions', function ($table) {
$table->string('txn', 32)->unique()->after('wallet_id');
});
}

/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
//
}
}

0 comments on commit dd81d25

Please sign in to comment.