Issues (97)

src/Traits/MorphOneWallet.php (1 issue)

Labels
Severity
1
<?php
2
3
namespace Bavix\Wallet\Traits;
4
5
use Bavix\Wallet\Models\Wallet as WalletModel;
6
use Illuminate\Database\Eloquent\Relations\MorphOne;
7
8
/**
9
 * Trait MorphOneWallet.
10
 * @property-read WalletModel $wallet
11
 */
12
trait MorphOneWallet
13
{
14
    /**
15
     * Get default Wallet
16
     * this method is used for Eager Loading.
17
     *
18
     * @return MorphOne|WalletModel
19
     */
20 117
    public function wallet(): MorphOne
21
    {
22 117
        return ($this instanceof WalletModel ? $this->holder : $this)
23 117
            ->morphOne(config('wallet.wallet.model', WalletModel::class), 'holder')
0 ignored issues
show
It seems like morphOne() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

23
            ->/** @scrutinizer ignore-call */ morphOne(config('wallet.wallet.model', WalletModel::class), 'holder')
Loading history...
24 117
            ->where('slug', config('wallet.wallet.default.slug', 'default'))
25 117
            ->withDefault([
26 117
                'name' => config('wallet.wallet.default.name', 'Default Wallet'),
27 117
                'slug' => config('wallet.wallet.default.slug', 'default'),
28 117
                'balance' => 0,
29
            ]);
30
    }
31
}
32