/** * Store a newly created resource in storage. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ public function store(PagoUpdateRequest $request) { if ($request->ajax()) { $id_site = \Session::get('id_site'); $id_user = $request->id_user; $user = User::find($id_user); $cuota = Cuotas::find($user->type); $pagos = DB::table('pagos')->where('id_user', $id_user)->where('id_site', $id_site)->get(); $newDate = explode("-", $request->date); $flag = true; if (empty($pagos)) { DB::table('pagos')->insert(['id_user' => $id_user, 'date' => $request->date, 'status' => $request->status, 'amount' => $cuota->amount, 'user_name' => $user->name, 'id_site' => $id_site]); $data = ['msg' => 'pago generado', 'subj' => 'Pago acreditado', 'user_mail' => $user->email]; Mail::send('emails.msg', $data, function ($msj) use($data) { $msj->subject($data['subj']); $msj->to($data['user_mail']); }); return response()->json(["tipo" => 'success']); } else { foreach ($pagos as $value) { $date = explode("-", $value->date); if ($date[0] == $newDate[0] && $date[1] == $newDate[1]) { $flag = false; break; } } if ($flag) { $ultimo = DB::table('pagos')->where('id_user', $id_user)->where('id_site', $id_site)->orderBy('date', 'dsc')->take(1)->value('date'); //get next year and month $ultimo_pago = explode("-", $ultimo); if (intval($ultimo_pago[1]) == 12) { $next_m = 1; $next_y = intval($ultimo_pago[0]) + 1; } else { $next_m = intval($ultimo_pago[1]) + 1; $next_y = intval($ultimo_pago[0]); } if (intval($newDate[0]) == $next_y && intval($newDate[1]) == $next_m) { DB::table('pagos')->insert(['id_user' => $id_user, 'date' => $request->date, 'status' => $request->status, 'amount' => $cuota->amount, 'user_name' => $user->name, 'id_site' => $id_site]); $data = ['msg' => 'pago generado', 'subj' => 'Pago acreditado', 'user_mail' => $user->email]; Mail::send('emails.msg', $data, function ($msj) use($data) { $msj->subject($data['subj']); $msj->to($data['user_mail']); }); return response()->json(["tipo" => 'success']); } else { return response()->json(["tipo" => 'fail', "message" => 'No estan permitido intervalos sin pagos creados. Se debe crear un pago con fecha inmediata al ultimo creado.']); } } else { return response()->json(["tipo" => 'fail', "message" => 'Ya existe un pago para este mes y usuario.']); } } } // end request ajax }
/** * Create a new user instance after a valid registration. * * @param array $data * @return User */ protected function create(array $data) { return User::create(['name' => $data['name'], 'email' => $data['email'], 'password' => bcrypt($data['password'])]); }
public function loadData(Request $request) { /* Excel::load('file/file.xlsx', function($file) { $result=$file->get(); foreach ($result as $key => $value) { echo $value->nombre.'--'.$value->email.'--'.$value->direccion.'<br>'; } })->get(); */ if ($request->hasFile('file')) { $file = $request->file('file'); $result = Excel::load($file)->get(); } //$result = Excel::load('file/file.xlsx')->get(); /* return response()->json( $result->toArray() ); */ $users = User::all(); $tipos = Cuotas::lists('concepto', 'id'); return view('/admin/usuarios', ['users' => $users, 'tipos' => $tipos, 'result' => $result]); }
public function getPaymentStatus() { // Get the payment ID before session clear $payment_id = \Session::get('paypal_payment_id'); // clear the session payment ID \Session::forget('paypal_payment_id'); $payerId = \Input::get('PayerID'); $token = \Input::get('token'); //if (empty(\Input::get('PayerID')) || empty(\Input::get('token'))) { if (empty($payerId) || empty($token)) { return redirect()->to('micuenta')->with('error', 'Hubo un problema al intentar pagar con Paypal'); } $payment = Payment::get($payment_id, $this->_api_context); // PaymentExecution object includes information necessary // to execute a PayPal account payment. // The payer_id is added to the request query parameters // when the user is redirected from paypal back to your site $execution = new PaymentExecution(); $execution->setPayerId(\Input::get('PayerID')); //Execute the payment $result = $payment->execute($execution, $this->_api_context); //echo '<pre>';print_r($result);echo '</pre>';exit; // DEBUG RESULT, remove it later if ($result->getState() == 'approved') { // payment made // Registrar el pedido --- ok // Registrar el Detalle del pedido --- ok // Enviar correo a user // Enviar correo a admin // Redireccionar // Update de pagos $pagos_id = \Session::get('pagos_id'); $pagos_data = \Session::get('pagos_data'); $message = 'Su pago ha sido registrado. Gracias.'; if (!empty($pagos_id)) { foreach ($pagos_id as $pago) { DB::table('pagos')->where('id', $pago)->update(['status' => 1]); DB::table('users')->where('id', $this->auth->user()->id)->update(['status' => 1]); } } else { if (!empty($pagos_data)) { $user = User::find($this->auth->user()->id); $cuota = Cuotas::find($user->type); foreach ($pagos_data as $date) { DB::table('pagos')->insert(['id_user' => $user->id, 'date' => $date, 'status' => 1, 'amount' => $cuota->amount, 'user_name' => $user->name]); } } } return redirect()->to('micuenta')->with('message', $message); } return redirect()->to('micuenta')->with('message', 'El pago ha sido cancelado.'); }
public function update_info_user($id, UserUpdateRequest $request) { $user = User::find($id); $user->fill($request->all()); $user->save(); return response()->json(["message" => 'listo']); }
public function usuarios() { if ($this->auth->user()->role == 1) { $users = User::all(); return view('/admin/usuarios', ['users' => $users]); } else { return Redirect::to('home'); } }
/** * Create a new user instance after a valid registration. * * @param array $data * @return User */ protected function create(array $data) { return User::create(['name' => $data['name'], 'email' => $data['email']]); }
/** * Remove the specified resource from storage. * * @param int $id * @return \Illuminate\Http\Response */ public function destroy($id) { $user = User::find($id); $user->delete(); return response()->json(["mensaje" => 'eliminado']); }
public function sendEmailMsg(Request $request, $id) { $user = User::findOrFail($id); $data = ['msg' => $request->input('msg'), 'subj' => $request->input('subj'), 'user_mail' => $user->email]; /* Mail::later(5, 'emails.msg', $data , function ($msj) use ($user) { $msj->subject('Email'); $msj->to($user->email); }); */ Mail::send('emails.msg', $data, function ($msj) use($data) { $msj->subject($data['subj']); $msj->to($data['user_mail']); }); return response()->json(["message" => 'listo']); }