| Total Complexity | 4 |
| Total Lines | 51 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 9 | class CreateTransfersTable extends Migration |
||
| 10 | { |
||
| 11 | |||
| 12 | /** |
||
| 13 | * @return string |
||
| 14 | */ |
||
| 15 | protected function transactionTable(): string |
||
| 16 | { |
||
| 17 | return (new Transaction())->getTable(); |
||
| 18 | } |
||
| 19 | |||
| 20 | /** |
||
| 21 | * @return string |
||
| 22 | */ |
||
| 23 | protected function table(): string |
||
| 24 | { |
||
| 25 | return (new Transfer())->getTable(); |
||
| 26 | } |
||
| 27 | |||
| 28 | /** |
||
| 29 | * @return void |
||
| 30 | */ |
||
| 31 | public function up(): void |
||
| 32 | { |
||
| 33 | Schema::create($this->table(), function(Blueprint $table) { |
||
| 34 | $table->increments('id'); |
||
| 35 | $table->morphs('from'); |
||
| 36 | $table->morphs('to'); |
||
| 37 | $table->unsignedInteger('deposit_id'); |
||
| 38 | $table->unsignedInteger('withdraw_id'); |
||
| 39 | $table->uuid('uuid')->unique(); |
||
| 40 | $table->timestamps(); |
||
| 41 | |||
| 42 | $table->foreign('deposit_id') |
||
| 43 | ->references('id') |
||
| 44 | ->on($this->transactionTable()) |
||
| 45 | ->onDelete('cascade'); |
||
| 46 | |||
| 47 | $table->foreign('withdraw_id') |
||
| 48 | ->references('id') |
||
| 49 | ->on($this->transactionTable()) |
||
| 50 | ->onDelete('cascade'); |
||
| 51 | }); |
||
| 52 | } |
||
| 53 | |||
| 54 | /** |
||
| 55 | * @return void |
||
| 56 | */ |
||
| 57 | public function down(): void |
||
| 58 | { |
||
| 59 | Schema::drop($this->table()); |
||
| 60 | } |
||
| 63 |