bavix / laravel-wallet

It's easy to work with a virtual wallet
https://bavix.github.io/laravel-wallet/
MIT License
1.15k stars 230 forks source link

Bavix\Wallet\Internal\Exceptions\TransactionFailedException Transaction failed #425

Closed zenklot closed 2 years ago

zenklot commented 2 years ago

in my user model I extend to use Illuminate\Foundation\Auth\User as Authenticatable;

namespace App\Models;

use App\Notifications\VerifyEmailQueued;
use Illuminate\Contracts\Auth\MustVerifyEmail;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
use Laravel\Sanctum\HasApiTokens;
use Spatie\Permissions\Traits\HasRoles;
use Bavix\Wallet\Traits\HasWallet;
use Bavix\Wallet\Interfaces\Wallet;

class User extends Authenticable implements MustVerifyEmail, Wallet
{
    use HasApiTokens, HasFactory, Notifiable, HasRoles, HasWallet;

    /**
     * The attributes that are mass assignable.
     *....

and in controller I use basic usage

class TransactionController extends Controller
{
    /**
     * Display a listing of the resources.
     *
     * @return \Illuminate\Http\Response
     */
    public function index()
    {
         $user = User::first();
         $user->balance; // 0
    }

but displays the error message Bavix\Wallet\Internal\Exceptions\TransactionFailedException Transaction failed. is this caused by extends to Authenticatable ?

rez1dent3 commented 2 years ago

@zenklot hello. I need a full error trace.

zenklot commented 2 years ago

@zenklot hello. I need a full error trace.

https://flareapp.io/share/OmVKRa4P

rez1dent3 commented 2 years ago

@zenklot https://flareapp.io/share/OmVKRa4P#F59 Wallet cannot be created. It is more likely that not all migrations have passed for you.

zenklot commented 2 years ago

after i created a new laravel project, i know where the error is, because i changed the primary key in the user model to email then an error occurred but after i returned it to the id then the problem was not there.