Пример #1
0
 /**
  * @GET("profile/transactions", as="profile.transactions")
  * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
  */
 public function index()
 {
     $user_id = \Auth::user()->id;
     $purchases = Purchase::where('user_id', $user_id)->get();
     $deposits = Deposit::where('user_id', $user_id)->get();
     $pulloffmoneys = PullOffMoney::where('user_id', $user_id)->get();
     return view('transactions.index', compact('purchases', 'deposits', 'pulloffmoneys'));
 }
 /**
  * @POST("/pulloffmoney/{id}", as="admin.pulloffmoney.status")
  * @param $id
  * @param Request $request
  * @return \Illuminate\Http\RedirectResponse
  */
 public function status_update($id, Request $request)
 {
     $bank = Banks::find(1);
     $pull = PullOffMoney::findORFail($id);
     $pull->status = $request->input('status');
     $pull->update();
     $bank->amount -= $pull->amount;
     $bank->update();
     return redirect()->back();
 }
Пример #3
0
 /**
  * @POST("/profile/pulloffmoney", as="profile.pulloffmoney.store")
  * @param PullOffMoney $pulloffmoney
  * @param Request $request
  * @return \Illuminate\Http\RedirectResponse
  */
 public function store(PullOffMoney $pulloffmoney, Request $request)
 {
     $user = \Auth::user();
     $amount = $request->input('amount');
     if ($amount <= 1) {
         \Session::flash('message', 'Некорректная сумма!');
         return back();
     }
     if ($amount > $user->balance) {
         \Session::flash('message', 'Недостаточно средств или некорректная сумма!');
         return back();
     } else {
         $pulloffmoney->fill($request->all());
         $pulloffmoney->user()->associate($user);
         $pulloffmoney->save();
         $user->balance -= $amount;
         $user->update();
         return redirect()->route('profile.show')->with('message', 'Заявка на вывод сделана! Спасибо, что доверяете нам!');
     }
 }