bavix / laravel-wallet

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

ErrorException Trying to get property 'exists' of non-object #286

Closed odion-cloud closed 3 years ago

odion-cloud commented 3 years ago

this is my code when i try to do transfer , but i get ErrorException Trying to get property 'exists' of non-object

/**
 * Store a newly created resource in storage.
 *
 * @param  \Illuminate\Http\Request  $request
 * @return \Illuminate\Http\Response
 */
public function store(Request $request)
{
    $first = User::find(auth()->user()->id); 
    // dd($first);
    $last = User::where('id','=',$request->id)->first(); // last user
    // dd($last);
    $first->getKey() !== $last->getKey(); // true
    // dd((int)$request->amount);
    $first->transfer($last, (int)$request->amount); 
    return redirect()->back()->with('success','transfer was successful');
}
rez1dent3 commented 3 years ago

@odion-cloud Hello. I can not catch this error, I am missing data. Added a unit test to your case and it works. https://github.com/bavix/laravel-wallet/commit/aa7359627bb3db5f5acdb935babb3f035259446a

rez1dent3 commented 3 years ago

245

odion-cloud commented 3 years ago

can you please the logic to transfer from one user to the other

rez1dent3 commented 3 years ago

@odion-cloud Continue to issue #245