Exemplo n.º 1
0
 public function declineSave($withdrawId, Request $request)
 {
     $rules = ['comment' => 'required|min:5|max:255'];
     $this->validate($request, $rules);
     $withdrawal = Withdrawal::findOrFail($withdrawId);
     $withdrawal->admin_id = $this->user->id;
     $withdrawal->admin_comment = $request->get('comment');
     $withdrawal->status = 'declined';
     $user = $withdrawal->user;
     $user->balance_blocked = $user->balance_blocked - $withdrawal->amount;
     if ($user->balance_blocked < 0) {
         $user->balance_blocked = 0;
     }
     $withdrawal->save();
     $user->save();
     NotificationMapper::withdrawDecline($withdrawal);
     LogMapper::log('withdraw_decline', $withdrawal->id, $withdrawal->amount, $withdrawal->toArray());
     return redirect('/admin/withdraw/' . $withdrawal->id . '/show')->with(['success' => 'Withdraw declined']);
 }
Exemplo n.º 2
0
 public static function withdrawal(User $user, $limit = 50)
 {
     return Withdrawal::whereUserId($user->id)->paginate($limit);
 }