| Total Complexity | 4 |
| Total Lines | 55 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 0 | ||
| 1 | <?php |
||
| 25 | class Transaction extends Model |
||
| 26 | { |
||
| 27 | |||
| 28 | public const TYPE_DEPOSIT = 'deposit'; |
||
| 29 | public const TYPE_WITHDRAW = 'withdraw'; |
||
| 30 | |||
| 31 | /** |
||
| 32 | * @var array |
||
| 33 | */ |
||
| 34 | protected $fillable = [ |
||
| 35 | 'payable_type', |
||
| 36 | 'payable_id', |
||
| 37 | 'wallet_id', |
||
| 38 | 'uuid', |
||
| 39 | 'type', |
||
| 40 | 'amount', |
||
| 41 | 'confirmed', |
||
| 42 | 'meta', |
||
| 43 | ]; |
||
| 44 | |||
| 45 | /** |
||
| 46 | * @var array |
||
| 47 | */ |
||
| 48 | protected $casts = [ |
||
| 49 | 'amount' => 'int', |
||
| 50 | 'confirmed' => 'bool', |
||
| 51 | 'meta' => 'json' |
||
| 52 | ]; |
||
| 53 | 39 | ||
| 54 | /** |
||
| 55 | 39 | * @return string |
|
| 56 | 39 | */ |
|
| 57 | public function getTable(): string |
||
| 58 | { |
||
| 59 | 39 | if (!$this->table) { |
|
| 60 | $this->table = \config('wallet.transaction.table'); |
||
| 61 | } |
||
| 62 | |||
| 63 | return parent::getTable(); |
||
| 64 | } |
||
| 65 | 6 | ||
| 66 | /** |
||
| 67 | 6 | * @return MorphTo |
|
| 68 | */ |
||
| 69 | public function payable(): MorphTo |
||
| 70 | { |
||
| 71 | return $this->morphTo(); |
||
| 72 | } |
||
| 73 | |||
| 74 | /** |
||
| 75 | * @return BelongsTo |
||
| 76 | */ |
||
| 77 | public function wallet(): BelongsTo |
||
| 80 | } |
||
| 81 | |||
| 82 | } |
||
| 83 |
Let?s assume that you have a directory layout like this:
. |-- OtherDir | |-- Bar.php | `-- Foo.php `-- SomeDir `-- Foo.phpand let?s assume the following content of
Bar.php:If both files
OtherDir/Foo.phpandSomeDir/Foo.phpare loaded in the same runtime, you will see a PHP error such as the following:PHP Fatal error: Cannot use SomeDir\Foo as Foo because the name is already in use in OtherDir/Foo.phpHowever, as
OtherDir/Foo.phpdoes not necessarily have to be loaded and the error is only triggered if it is loaded beforeOtherDir/Bar.php, this problem might go unnoticed for a while. In order to prevent this error from surfacing, you must import the namespace with a different alias: