Exemplo n.º 1
0
 /**
  * Store a newly created resource in storage.
  *
  * @param Deposit $deposit
  * @param  \Illuminate\Http\Request $request
  * @return \Illuminate\Http\Response
  */
 public function store(Deposit $deposit, Request $request)
 {
     if ((int) $request->input('amount') > Auth::user()->balance) {
         \Session::flash('message', 'Недостаточно средств!');
         return redirect('/profile');
     } elseif ($request->input('amount') <= 0) {
         \Session::flash('message', 'Введите корректную сумму!');
         return back();
     } else {
         $bank = Banks::where('banks_profiles_id', 2)->first();
         $data = $request->all();
         $data['days'] = $request->input('days');
         $data['percent'] = $request->input('percent');
         $data['conclusion'] = Carbon::now()->addDays((int) $request->input('days'));
         $user = User::find($request->input('user_id'));
         $plan = Plan::find($request->input('currency_id'));
         $deposit->fill($data);
         $deposit->user()->associate($user);
         $deposit->plan()->associate($plan);
         $bank->amount += (int) $request->input('amount');
         $bank->update();
         $user->balance -= (int) $request->input('amount');
         $user->update();
         $deposit->save();
         \Session::flash('message', 'Вы успешно сделали вклад! Для получения информации по вкладам перейдите в "Мои операции"');
         return redirect('/profile');
     }
 }
 /**
  * @POST("/requests/moderation/{id}", as="admin.requests.moderation")
  * @param Request $request
  * @param $id
  * @return \Illuminate\Http\RedirectResponse
  */
 public function moderation(Request $request, $id)
 {
     $purchase = Purchase::find($id);
     $user = User::where('id', $purchase->user_id)->first();
     if (\Auth::user()->hasRole('supervisor')) {
         $purchase->status_moderation = $request->input('status_moderation');
         $purchase->update();
         return back();
     } elseif (\Auth::user()->hasRole('admin')) {
         if ($purchase->status_trust == 0 && $purchase->type_id != 3) {
             $bank = Banks::where('banks_profiles_id', 1)->first();
             if ($minus = $request->input('minus')) {
                 $total = $purchase->total -= $minus;
                 $bank->amount -= $total;
                 $bank->update();
             } else {
                 $bank->amount -= $purchase->total;
                 $bank->update();
             }
         } elseif ($purchase->status_trust == 1) {
             if ($minus = $request->input('minus')) {
                 $total = $purchase->total -= $minus;
                 $user->balance += $total;
                 $user->update();
             } else {
                 $user->balance += $purchase->total;
                 $user->update();
             }
         } elseif ($purchase->type_id == 3) {
             $bank = Banks::where('banks_profiles_id', 1)->first();
             if ($minus = $request->input('minus')) {
                 $total = $purchase->total -= $minus;
                 $bank->amount += $total;
                 $bank->update();
                 $user->balance += $total;
                 $user->update();
             } else {
                 $bank->amount += $purchase->total;
                 $bank->update();
                 $user->balance += $purchase->total;
                 $user->update();
             }
         }
         $purchase->status_admin = $request->input('status_admin');
         $purchase->update();
         return back();
     }
 }
Exemplo n.º 3
0
 /**
  * @POST("/profile/deposits/{id}")
  * @param $id
  * @param Request $request
  * @return \Illuminate\Http\RedirectResponse
  */
 public function update($id, Request $request)
 {
     $user = \Auth::user();
     $bank = Banks::where('banks_profiles_id', 2)->first();
     $deposit = Deposit::findOrFail($id);
     if ($deposit->conclusion <= new \DateTime() && $deposit->status == 0) {
         $deposit->status = $request->input('status');
         $deposit->update();
         $bank->amount -= $deposit->total;
         $bank->update();
         $user->balance += $deposit->total;
         $user->update();
         \Session::flash('message', 'Вывод успешно завершен! Спасибо, что доверяете нам!');
         return redirect()->route('profile.index');
     } else {
         return redirect()->route('profile.index')->with('message', 'Ошибка вывода!');
     }
 }
Exemplo n.º 4
0
 public static function bankName($id)
 {
     return \App\Models\Banks::where('id', $id)->first()->name;
 }