/**
  * 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("/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();
 }
 /**
  * @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();
     }
 }
示例#4
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', 'Ошибка вывода!');
     }
 }
示例#5
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getBank()
 {
     return $this->hasOne(Banks::className(), ['id' => 'bankID']);
 }
示例#6
0
 public static function banksFilter($param = "")
 {
     $data = \App\Models\Banks::all();
     $selecttop = '<select name="bank_id" id="bank_id"  class="form-control select2">';
     $option = '<option value="">- Pilih Bank -</option>';
     foreach ($data as $key => $value) {
         $option = $option . "<option value='{$value->id}'>{$value->id} - {$value->name}</option>";
     }
     $selectbottom = '</select>';
     $list = $selecttop . $option . $selectbottom;
     return $list;
 }
 public function deleteBank($id)
 {
     $data = Banks::deleteBank($id);
     return response()->json($data);
 }
示例#8
0
 public function buildForm()
 {
     $this->add('bank_id', 'select', ['attr' => ['class' => 'frm-e form-control'], 'choices' => \App\Models\Banks::lists("name", "id")->toArray(), 'empty_value' => '- Select Banks -', 'label' => 'Bank'])->add('area_id', 'select', ['attr' => ['class' => 'frm-e form-control'], 'choices' => \App\Models\Areas::lists("name_area", "id")->toArray(), 'empty_value' => '- Select Area-', 'label' => 'Area'])->add('location_id', 'select', ['attr' => ['class' => 'frm-e form-control'], 'choices' => \App\Models\Locations::lists("name", "id")->toArray(), 'empty_value' => '- Select Lokasi-', 'label' => 'Lokasi'])->add('machine_id', 'select', ['attr' => ['class' => 'frm-e form-control'], 'choices' => \App\Models\Machines::lists("name_machine", "id")->toArray(), 'empty_value' => '- Pilih Mesin -', 'label' => 'Mesin'])->add('from', 'text', ['attr' => ['class' => 'form-control datepicker1', 'required' => 'true']])->add('to', 'text', ['attr' => ['class' => 'form-control datepicker2', 'required' => 'true']])->add('format', 'choice', ['choices' => ['pdf' => 'PDF', 'csv' => 'CSV', 'xls' => 'XLS'], 'attr' => ['required' => 'true'], 'label' => "Format", 'choice_options' => ['wrapper' => ['class' => 'choice-wrapper']]]);
 }
 /**
  * Update the specified resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  Banks $bank
  * @return \Illuminate\Http\Response
  */
 public function update(Request $request, Banks $bank)
 {
     $bank->fill($request->all())->update();
     return redirect()->route('admin.bank.index');
 }