/**
  * Store a newly created resource in storage.
  * POST /users
  *
  * @return Response
  */
 public function store()
 {
     Input::merge(array_map('trim', Input::all()));
     $input = Input::all();
     $validation = Validator::make($input, User::$rules);
     if ($validation->passes()) {
         DB::transaction(function () {
             $user = new User();
             $user->first_name = strtoupper(Input::get('first_name'));
             $user->middle_initial = strtoupper(Input::get('middle_initial'));
             $user->last_name = strtoupper(Input::get('last_name'));
             $user->dept_id = Input::get('department');
             $user->confirmed = 1;
             $user->active = 1;
             $user->email = Input::get('email');
             $user->username = Input::get('username');
             $user->password = Input::get('password');
             $user->password_confirmation = Input::get('password_confirmation');
             $user->confirmation_code = md5(uniqid(mt_rand(), true));
             $user->image = "default.png";
             $user->save();
             $role = Role::find(Input::get('name'));
             $user->roles()->attach($role->id);
         });
         return Redirect::route('user.index')->with('class', 'success')->with('message', 'Record successfully added.');
     } else {
         return Redirect::route('user.create')->withInput(Input::except(array('password', 'password_confirmation')))->withErrors($validation)->with('class', 'error')->with('message', 'There were validation errors.');
     }
 }
示例#2
0
 public function postRegistro()
 {
     include_once public_path() . '/securimage/securimage.php';
     $securimage = new Securimage();
     $captcha_sesion = strtoupper($securimage->getCode());
     include app_path() . "/include/cifrado.php";
     $usuario = new Usuario();
     $data = Input::all();
     $data['captcha_sesion'] = $captcha_sesion;
     $data['captcha_code'] = strtoupper($data['captcha_code']);
     $data['fecha_nacimiento'] = $data['anyo'] . "-" . $data['mes'] . "-" . $data['dia'];
     foreach ($data as $key => $value) {
         if ($key != 'password' && $key != 'email') {
             $data[$key] = mb_strtoupper($value, 'UTF-8');
         }
     }
     $data['password'] = encriptar($data['password']);
     $data['cod_verif'] = rand(111111, 999999);
     if (!$usuario->isValid($data)) {
         return Redirect::action('Usuario_UsuarioController@getRegistro')->withInput(Input::except('password'))->withErrors($usuario->errors)->with('id_municipio', $data['municipio']);
     }
     $usuario->fill($data);
     $usuario->save();
     return Redirect::action('Usuario_UsuarioController@getVerificar', array($usuario->id))->with('message_ok', 'Registro Completado. 
 			Por favor, inserte el código de verificación que le hemos enviado a su correo electrónico. Gracias');
 }
示例#3
0
 public function doLogin()
 {
     // validate the info, create rules for the inputs
     $rules = array('email' => 'required|email', 'password' => 'required|alphaNum|min:3');
     // run the validation rules on the inputs from the form
     $validator = Validator::make(Input::all(), $rules);
     // if the validator fails, redirect back to the form
     if ($validator->fails()) {
         return Redirect::to('login')->withErrors($validator)->withInput(Input::except('password'));
         // send back the input (not the password) so that we can repopulate the form
     } else {
         // create our user data for the authentication
         $userdata = array('email' => Input::get('email'), 'password' => Input::get('password'));
         // attempt to do the login
         if (Auth::attempt($userdata)) {
             // validation successful!
             // redirect them to the secure section or whatever
             // return Redirect::to('secure');
             // for now we'll just echo success (even though echoing in a controller is bad)
             echo 'SUCCESS!';
         } else {
             // validation not successful, send back to form
             return Redirect::to('login');
         }
     }
 }
 public function updateProfile()
 {
     $name = Input::get('name');
     //$username = Input::get('username');
     $birthday = Input::get('birthday');
     $bio = Input::get('bio', '');
     $gender = Input::get('gender');
     $mobile_no = Input::get('mobile_no');
     $country = Input::get('country');
     $old_avatar = Input::get('old_avatar');
     /*if(\Cashout\Models\User::where('username',$username)->where('id','!=',Auth::user()->id)->count()>0){
           Session::flash('error_msg', 'Username is already taken by other user . Please enter a new username');
           return Redirect::back()->withInput(Input::all(Input::except(['_token'])));
       }*/
     try {
         $profile = \Cashout\Models\User::findOrFail(Auth::user()->id);
         $profile->name = $name;
         // $profile->username = $username;
         $profile->birthday = $birthday;
         $profile->bio = $bio;
         $profile->gender = $gender;
         $profile->mobile_no = $mobile_no;
         $profile->country = $country;
         $profile->avatar = Input::hasFile('avatar') ? \Cashout\Helpers\Utils::imageUpload(Input::file('avatar'), 'profile') : $old_avatar;
         $profile->save();
         Session::flash('success_msg', 'Profile updated successfully');
         return Redirect::back();
     } catch (\Exception $e) {
         Session::flash('error_msg', 'Unable to update profile');
         return Redirect::back()->withInput(Input::all(Input::except(['_token', 'avatar'])));
     }
 }
 /**
  * Update the specified resource in storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function update($id)
 {
     //Validate
     $rules = array('name' => 'required');
     $validator = Validator::make(Input::all(), $rules);
     // process the validation
     if ($validator->fails()) {
         return Redirect::back()->withErrors($validator)->withInput(Input::except('password'));
     } else {
         // Update
         $commodity = Commodity::find($id);
         $commodity->name = Input::get('name');
         $commodity->description = Input::get('description');
         $commodity->metric_id = Input::get('unit_of_issue');
         $commodity->unit_price = Input::get('unit_price');
         $commodity->item_code = Input::get('item_code');
         $commodity->storage_req = Input::get('storage_req');
         $commodity->min_level = Input::get('min_level');
         $commodity->max_level = Input::get('max_level');
         try {
             $commodity->save();
             return Redirect::route('commodity.index')->with('message', trans('messages.success-updating-commodity'))->with('activecommodity', $commodity->id);
         } catch (QueryException $e) {
             Log::error($e);
         }
     }
 }
 public function postLogin()
 {
     // Get all the inputs
     // id is used for login, username is used for validation to return correct error-strings
     $userdata = array('id' => Input::get('username'), 'username' => Input::get('username'), 'password' => Input::get('password'));
     // Declare the rules for the form validation.
     $rules = array('username' => 'Required', 'password' => 'Required');
     // Validate the inputs.
     $validator = Validator::make($userdata, $rules);
     // Check if the form validates with success.
     if ($validator->passes()) {
         // remove username, because it was just used for validation
         unset($userdata['username']);
         // Try to log the user in.
         if (Auth::attempt($userdata)) {
             // Redirect to homepage
             return Redirect::to('')->with('success', 'You have logged in successfully');
         } else {
             // Redirect to the login page.
             return Redirect::to('login')->withErrors(array('password' => 'Password invalid'))->withInput(Input::except('password'));
         }
     }
     // Something went wrong.
     return Redirect::to('login')->withErrors($validator)->withInput(Input::except('password'));
 }
 public function createStudent()
 {
     $validator = $this->validateStudent(Input::all());
     if ($validator->fails()) {
         $messages = $validator->messages();
         return Redirect::to('student-new')->withErrors($messages)->withInput(Input::except('password', 'password_confirmation'));
     }
     $input = Input::all();
     //$input['dob'] = date('m-d-Y H:i:s', strtotime(Input::get('dob')));
     $input['collegename'] = Admin::where('collegeid', '=', Session::get('user')->collegeid)->first()->collegename;
     $input['collegeid'] = Session::get('user')->collegeid;
     //$input['collegeid']="dummy";
     //$input['collegename']="dummy";
     $user = new User();
     $user->email = $input['email'];
     $user->password = Hash::make($input['password']);
     $user->collegeid = $input['collegeid'];
     $user->flag = 3;
     $user->save();
     $input['loginid'] = $user->id;
     if (Input::hasFile('profilepic')) {
         $input['profilepic'] = $this->filestore(Input::file('profilepic'), $user->id);
     }
     $removed = array('password', 'password_confirmation');
     foreach ($removed as $k) {
         unset($input[$k]);
     }
     Student::saveFormData($input);
     return Redirect::to('student');
 }
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     $uId = \Input::get('user_id');
     $date = \Input::get('date');
     $check = \Payment::where('emp_id', '=', $uId)->where('pay_date', '=', $date)->first();
     if ($check) {
         echo '{"error":"already exits"}';
         return;
     } else {
         $earn = \Input::get('earned');
         $deduction = \Input::get('deducted');
         $net = \Input::get('net');
         $description = \Input::except('earned', 'deducted', 'net', 'date', 'date_of_salary', '_token', 'user_id');
         $description = json_encode($description);
         $insert = \Payment::insertGetId(array('emp_id' => $uId, 'earning_amount' => $earn, 'deducting_amount' => $deduction, 'total_amount' => $net, 'pay_date' => $date, 'description' => $description));
         if ($insert) {
             $ids = array('uId' => $uId, 'date' => $date, 'eId' => $insert);
             $msg = array('success' => json_encode($ids));
             echo json_encode($msg);
             return;
         } else {
             echo '{"error":"already exits"}';
             return;
         }
     }
 }
 public function updateUser($user_id)
 {
     $name = Input::get('name');
     $birthday = Input::get('birthday');
     $bio = Input::get('bio', '');
     $gender = Input::get('gender');
     $mobile_no = Input::get('mobile_no');
     $country = Input::get('country');
     $old_avatar = Input::get('old_avatar');
     $password = Input::get('password');
     $password_confirmation = Input::get('password_confirmation');
     try {
         $profile = \Cashout\Models\User::findOrFail($user_id);
         $profile->name = $name;
         $profile->birthday = $birthday;
         $profile->bio = $bio;
         $profile->gender = $gender;
         $profile->mobile_no = $mobile_no;
         $profile->country = $country;
         $profile->avatar = Input::hasFile('avatar') ? \Cashout\Helpers\Utils::imageUpload(Input::file('avatar'), 'profile') : $old_avatar;
         if (strlen($password) > 0 && strlen($password_confirmation) > 0 && $password == $password_confirmation) {
             $profile->password = Hash::make($password);
         }
         $profile->save();
         Session::flash('success_msg', 'Profile updated successfully');
         return Redirect::back();
     } catch (\Exception $e) {
         Session::flash('error_msg', 'Unable to update profile');
         return Redirect::back()->withInput(Input::all(Input::except(['_token', 'avatar'])));
     }
 }
示例#10
0
 public function doMeta()
 {
     $error = false;
     //  Set our metadata
     Metadata::set(Input::except(['user', 'pass', '_token']));
     Metadata::set('theme', 'default');
     //  Check the Stripe API key is valid
     try {
         Stripe::setApiKey(Metadata::item('stripe_key'));
         Stripe\Balance::retrieve();
     } catch (Exception $e) {
         $error = 'That Stripe key doesn’t look valid!';
     }
     //  Create the user
     if (User::whereEmail(Input::get('user'))->exists()) {
         //  We're installing, can't have users already (I think)
         // $error = 'Somebody’s already signed up with that email address!';
     } else {
         User::create(['username' => 'admin', 'name' => 'Administrator', 'level' => User::level('admin'), 'email' => Input::get('user'), 'password' => Input::get('pass')]);
     }
     if ($error === false) {
         return Redirect::to('install/done');
     }
     View::share('error', $error);
     return self::showMeta();
 }
 /**
  * Stores new account
  *
  * @return  Illuminate\Http\Response
  */
 public function store()
 {
     $repo = App::make('UserRepository');
     $user = $repo->signup(Input::all());
     if ($user->id) {
         try {
             if (Config::get('confide::signup_email')) {
                 Mail::queueOn(Config::get('confide::email_queue'), Config::get('confide::email_account_confirmation'), compact('user'), function ($message) use($user) {
                     $message->to($user->email, $user->username)->subject(Lang::get('confide::confide.email.account_confirmation.subject'));
                 });
             }
             $role = Role::where('name', '=', 'admin')->first();
             $user->roles()->attach($role->id);
             $notice_msg = 'Su cuenta ha sido creada satisfactoriamente. Revisa tu correo';
             return Redirect::action('UsersController@login')->with('notice', $notice_msg);
         } catch (Exception $exc) {
             $userReg = User::findOrFail($user->id);
             $userReg->delete(['id']);
             return Redirect::back()->with('error', 'Falló envío de correo, intente registrarse nuevamente');
         }
     } else {
         $error = $user->errors()->all(':message');
         return Redirect::back()->withInput(Input::except('password'))->with('error', $error);
     }
 }
 public function postStore()
 {
     $postData = Input::all();
     $rules = array('userName' => 'required|min:5', 'userEmail' => 'required|email', 'userMobile' => 'required|min:10|numeric', 'userAddress1' => 'required', 'userAddress2' => 'required', 'userPincode' => 'required|min:6|numeric', 'userCity' => 'required', 'userState' => 'required', 'userId' => 'required|alphanum');
     $validator = Validator::make($postData, $rules);
     if ($validator->fails()) {
         return Redirect::to('admin/profile')->withInput()->withErrors($validator);
     } else {
         if (Input::has('userKey')) {
             $rulespass = array('userKey' => 'required|min:6|alphanum', 'cpass' => 'required|min:6|same:userKey');
             $validator1 = Validator::make($postData, $rulespass);
             if ($validator1->fails()) {
                 return Redirect::to('admin/profile')->withInput()->withErrors($validator1);
             } else {
                 $input = json_encode(Input::except('_token', 'cpass'));
                 $update = Sample::update($input);
                 //print_r($update);exit;
                 if ($update && $update->status == "success") {
                     return Redirect::to('admin/profile')->with('success', $update->message);
                 } else {
                     return Redirect::to('admin/profile')->with('failure', "something went wrong");
                 }
             }
         } else {
             $input = json_encode(Input::except('_token', 'userKey', 'cpass'));
             $update = Sample::update($input);
             //print_r($update);exit;
             if ($update && $update->status == "success") {
                 return Redirect::to('admin/profile')->with('success', $update->message);
             } else {
                 return Redirect::to('admin/profile')->with('failure', "something went wrong");
             }
         }
     }
 }
 /**
  * Store a newly created resource in storage.
  * @access  public
  * @return Redirect
  */
 public function store()
 {
     // input data
     $data = Input::except('_token', 'search');
     // validation rules
     $rules = $this->getValidationRules();
     // validate data using rules
     $validator = Validator::make($data, $rules);
     if ($validator->fails()) {
         if (!$data['aou_list_id']) {
             $flashMessage = 'No sighting selected.';
         }
         return Redirect::to('/admin/trips/' . $data['trip_id'] . '/sightings')->withErrors($validator);
     } else {
         try {
             $sighting = new Sighting();
             $sighting->fill($data)->save();
             $flashMessage = 'Added sighting.';
         } catch (Exception $e) {
             $errorMessage = $e->getMessage();
             // most likely error is duplicate sighting; UNIQUE constraint violation
             if (stripos($errorMessage, 'duplicate entry') > 0) {
                 $errorMessage = 'Duplicate sighting.';
             }
             $flashMessage = $errorMessage;
         }
         return Redirect::to('/admin/trips/' . $data['trip_id'] . '/sightings')->with('flashMessage', $flashMessage);
     }
 }
 public function doLogin()
 {
     // process the form
     // validate the info, create rules for the inputs
     $rules = array('fname' => 'required', 'mobile' => 'required|integer');
     // run the validation rules on the inputs from the form
     $validator = Validator::make(Input::all(), $rules);
     // if the validator fails, redirect back to the form
     if ($validator->fails()) {
         return Redirect::to('login')->withErrors($validator)->withInput(Input::except('mobile'));
         // send back the input (not the password) so that we can repopulate the form
     } else {
         $plaintext_pwd = Input::get('mobile');
         // create our user data for the authentication
         $userdata = array('fname' => Input::get('fname'), 'password' => $plaintext_pwd);
         // attempt to do the login
         // 'remember me' activated
         if (Auth::attempt($userdata, true)) {
             // validation successful!
             // redirect them to the secure section or whatever
             // return Redirect::to('secure');
             // for now we'll just echo success (even though echoing in a controller is bad)
             return Redirect::route('dashboard');
             //return true;
         } else {
             // validation not successful, send back to form
             return Redirect::to('login')->withInput(Input::except('mobile'));
             //return false;
         }
     }
 }
 public function getIndex()
 {
     $data['solicitudes'] = Solicitud::eagerLoad()->aplicarFiltro(Input::except(['asignar', 'solo_asignadas', 'page', 'cerrar', 'anulando', '']))->ordenar();
     if (Input::has('asignar')) {
         $data['campo'] = Input::get('asignar');
         $data['solicitud'] = new Solicitud();
         if ($data['campo'] == 'usuario') {
             $usuario = Usuario::getLogged();
             $data['solicitudes']->whereDepartamentoId($usuario->departamento_id);
             $data['analistas'] = $usuario->getCompaneros();
         }
     } else {
         if (Input::has('anulando')) {
             $data['anulando'] = true;
         } else {
             if (Input::has('cerrar')) {
                 $data['cerrar'] = true;
             } else {
                 if (Input::has('solo_asignadas')) {
                     $data['solo_asignadas'] = true;
                 }
             }
         }
     }
     $data['solicitudes'] = $data['solicitudes']->paginate(5);
     //se usa para el helper de busqueda
     $data['persona'] = new Persona();
     $data['solicitud'] = new Solicitud();
     $data['presupuesto'] = new Presupuesto();
     $data['requerimiento'] = new Requerimiento();
     return View::make('solicitudes.index', $data);
 }
示例#16
0
 /**
  * Show all players
  * GET
  *
  * @param Request $request
  * @return Response
  */
 public function showCharacters(Request $request)
 {
     $name = $request->has('name') ? $request->input('name') : '';
     $min_level = $request->has('level_min') ? $request->input('level_min') : 20;
     $max_level = $request->has('level_max') ? $request->input('level_max') : 200;
     $breed = $request->has('breed') ? $request->input('breed') : [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12];
     $sex = $request->has('sex') ? $request->input('sex') : [0, 1];
     $sort = $request->has('sort') ? $request->input('sort') : '1B';
     switch ($sort) {
         case '1A':
             $column = 'xp';
             $sortBy = 'asc';
             break;
         case '1B':
             $column = 'xp';
             $sortBy = 'desc';
             break;
         case '2A':
             $column = 'name';
             $sortBy = 'asc';
             break;
         case '2B':
             $column = 'name';
             $sortBy = 'desc';
             break;
         default:
             $column = 'xp';
             $sortBy = 'desc';
             break;
     }
     $characters = PlayerManager::where('name', 'like', '%' . $name . '%')->whereBetween('level', [$min_level, $max_level])->whereIn('class', $breed)->whereIn('sexe', $sex)->orderBy($column, $sortBy)->paginate(20)->appends(\Input::except('page'));
     $countCharacters = PlayerManager::where('name', 'like', '%' . $name . '%')->whereBetween('level', [$min_level, $max_level])->whereIn('class', $breed)->whereIn('sexe', $sex)->count();
     return view('directories.characters', compact('characters', 'countCharacters'));
 }
示例#17
0
 /**
  * Log in to site.
  *
  * @return Response
  */
 public function login()
 {
     if (Auth::attempt(array('email' => Input::get('email'), 'password' => Input::get('password')), true) || Auth::attempt(array('username' => Input::get('email'), 'password' => Input::get('password')), true)) {
         return Redirect::intended('dashboard');
     }
     return Redirect::back()->withInput(Input::except('password'))->with('message', 'Wrong creadentials!');
 }
示例#18
0
 /**
  * Save user
  * 
  * @return \Illuminate\Http\JsonResponse
  */
 public function save()
 {
     $input = \Input::except('_token');
     $validator = \Validator::make($input, ['name' => 'required|max:255', 'email' => 'required|email|max:255|unique:users' . (!empty($input['id']) ? ',email,' . $input['id'] : ''), 'password' => empty($input['id']) ? 'required|confirmed|min:6' : 'confirmed|min:6']);
     // When fails
     if ($validator->fails()) {
         return response()->json(['errors' => $validator->messages()]);
     }
     // Save changes
     $user = empty($input['id']) ? new User() : User::find($input['id']);
     $user->fill($input);
     $user->save();
     // Change password
     if (!empty($input['password'])) {
         $user->password = \Hash::make($input['password']);
         $user->save();
     }
     // Update relations
     if (empty($input['id'])) {
         $input['roles'][] = 3;
     }
     $user->roles()->sync(empty($input['roles']) ? [] : $input['roles']);
     // Response
     return response()->json(['success' => 'Settings saved', 'redirect' => url('/admin/users/list')]);
 }
示例#19
0
 public function postPublish()
 {
     $msg = 'Report Successfully Published';
     $inputs = Input::except('notify');
     foreach (Input::all() as $key => $single_input) {
         if (empty($single_input) && (stristr($key, 'state') || stristr($key, 'city'))) {
             unset($inputs[$key]);
         }
     }
     $inputs['dob'] = GlobalFunc::set_date_format(Input::get('dob'));
     $inputs['found_date'] = GlobalFunc::set_date_format(Input::get('found_date'));
     if (!Input::hasFile('kid_image')) {
         unset($inputs['kid_image']);
     } else {
         $file = Input::file('kid_image');
         $destination_path = 'admin/images/upload/';
         $filename = str_random(15) . '.' . $file->getClientOriginalExtension();
         $file->move($destination_path, $filename);
         $inputs['kid_image'] = $destination_path . $filename;
     }
     if (Input::get('clicked') == 'Success') {
         // if the report is marked as a success
         $inputs['status'] = 9;
         $msg = 'Report Successfully Marked As Success';
     } else {
         //if the report is updated or published
         $inputs['status'] = 1;
     }
     unset($inputs['clicked']);
     Found::where('id', '=', Input::get('id'))->update($inputs);
     return Redirect::to('admin/found/published')->with('success', $msg);
 }
示例#20
0
 public function auth()
 {
     if (Auth::attempt(Input::except('_token'))) {
         return Redirect::route('home');
     }
     return Redirect::route('signin')->with('error', Lang::get('user.signin.error'))->withInput();
 }
示例#21
0
 public function edit($id)
 {
     if (Request::isMethod('post')) {
         $rules = array('title' => 'required|min:4', 'link' => 'required', 'content' => 'required|min:50', 'meta_description' => 'required|min:20', 'meta_keywords' => 'required');
         $validator = Validator::make(Input::all(), $rules);
         if ($validator->fails()) {
             return Redirect::to("admin/{$this->name}/{$id}/{$this->action}")->withErrors($validator)->withInput(Input::except(''));
         } else {
             $table = Page::find($id);
             $table->title = Input::get('title');
             $table->link = Input::get('link');
             $table->user_id = Auth::user()->id;
             $table->content = Input::get('content');
             $table->meta_title = Input::get('meta_title') ? Input::get('meta_title') : $table->title;
             $table->meta_description = Input::get('meta_description') ? Input::get('meta_description') : $table->description;
             $table->meta_keywords = Input::get('meta_keywords');
             $table->published_at = Page::toDate(Input::get('published_at'));
             $table->active = Input::get('active', 0);
             if ($table->save()) {
                 $name = trans("name.{$this->name}");
                 return Redirect::to("admin/{$this->name}")->with('success', trans("message.{$this->action}", ['name' => $name]));
             }
             return Redirect::to("admin/{$this->name}")->with('error', trans('message.error'));
         }
     }
     return View::make("admin.{$this->name}.{$this->action}", ['item' => Page::find($id), 'name' => $this->name, 'action' => $this->action]);
 }
 public function doRegister()
 {
     $rules = array('pwd' => 'required|min:3', 'pwd2' => 'required|same:pwd', 'user_email' => 'required|email|unique:users,email', 'terms' => 'required');
     $error_msg = array('same' => 'password must match', 'min:3' => 'the minimal length is 3', 'required' => 'This field is required', 'email' => 'Not a valid eamil address', 'email.unique' => 'This email address is exits');
     $validator = Validator::make(Input::all(), $rules, $error_msg);
     if ($validator->fails()) {
         //if validation fail
         $messages = $validator->messages();
         foreach ($messages->all() as $message) {
             echo $message;
         }
         return Redirect::to('register')->withErrors($validator)->withInput(Input::except('pwd', 'pwd2'));
     } else {
         // form inputs are validated
         /*$user_name = Input::get('username');*/
         $email = Input::get('user_email');
         //save new user
         $user = new User();
         $code = $this->generate_random_string(10);
         /*$user -> user_name = $user_name;*/
         $user->email = $email;
         $user->password = Hash::make(Input::get('pwd'));
         $user->activation_code = $code;
         $user->save();
         $mailContent = array('link' => 'http://deco3801-05.uqcloud.net/email_verify/' . $code, 'email' => $email);
         $user = array('email' => $email);
         Mail::send('emails.welcom', $mailContent, function ($message) use($user) {
             $message->to($user['email'])->subject('welcome to MoneyLink');
         });
         return Redirect::to('thankyou');
     }
 }
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function postCreate()
 {
     $rules = array('name' => 'required|alpha_dash|unique:roles,name', 'permissions' => 'required');
     // Validate the inputs
     $validator = Validator::make(Input::all(), $rules);
     // Check if the form validates with success
     if ($validator->passes()) {
         // Get the inputs, with some exceptions
         $inputs = Input::except('csrf_token');
         $this->role->name = $inputs['name'];
         $this->role->save();
         // Save permissions
         $this->role->savePermissions($inputs['permissions']);
         // Was the role created?
         if ($this->role->id) {
             // Redirect to the new role page
             return Redirect::to('admin/roles/' . $this->role->id . '/edit')->with('success', Lang::get('admin/roles/messages.create.success'));
         }
         // Redirect to the new role page
         return Redirect::to('admin/roles/create')->with('error', Lang::get('admin/roles/messages.create.error'));
         // Redirect to the role create page
         return Redirect::to('admin/roles/create')->withInput()->with('error', Lang::get('admin/roles/messages.' . $error));
     }
     // Form validation failed
     return Redirect::to('admin/roles/create')->withInput()->withErrors($validator);
 }
 public function store()
 {
     $userManager = new UserManagement();
     $this->accountAddValidator->addRule("company", "required");
     if (!$this->accountAddValidator->validate(Input::all())) {
         Session::flash('error_msg', Utils::buildMessages($this->accountAddValidator->getValidation()->messages()->all()));
         return Redirect::to('/customers/create')->withInput(Input::except("avatar"));
     } else {
         try {
             $user = $userManager->createUser(["name" => Input::get("name"), "email" => Input::get("email"), "password" => Input::get("password"), "password_confirmation" => Input::get("password_confirmation"), "birthday" => Input::get("birthday"), "bio" => Input::get("bio"), "mobile_no" => Input::get("mobile_no"), "country" => Input::get("country"), "gender" => Input::get("gender"), "avatar" => Input::hasFile('avatar') ? Utils::imageUpload(Input::file('avatar'), 'profile') : ''], 'customer', Input::has("activated"));
             $company_users = new CompanyCustomers();
             $company_users->customer_id = $user->id;
             $company_users->company_id = Input::get("company");
             $company_users->save();
             $this->mailer->welcome($user->email, $user->name, User::getWelcomeFields(false, $user->id, Input::get("password"), Input::get('company')));
             RecentActivities::createActivity("Customer <a href='/customers/all'>ID:" . $user->id . "</a> created by User ID:" . Auth::user()->id . " User Name:" . Auth::user()->name);
             if (!Input::has("activated")) {
                 $this->mailer->activate($user->email, $user->name, User::getActivateFields(false, $user->id, Input::get('company')));
             }
             Session::flash('success_msg', trans('msgs.customer_created_success'));
             return Redirect::to('/customers/all');
         } catch (\Exception $e) {
             Session::flash('error_msg', trans('msgs.unable_to_add_customer'));
             return Redirect::to('/customers/create')->withInput(Input::except("avatar"));
         }
     }
 }
示例#25
0
 /**
  * Update the specified resource in storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function update($id)
 {
     if (Auth::check()) {
         // validate
         // read more on validation at http://laravel.com/docs/validation
         $rules = array('username' => 'required', 'email' => 'required');
         $validator = Validator::make(Input::all(), $rules);
         // process the login
         if ($validator->fails()) {
             return Redirect::to('users/' . $id . '/edit')->withErrors($validator)->withInput(Input::except('password'));
         } else {
             // store
             $user = User::find($id);
             $user->username = Input::get('username');
             $user->email = Input::get('email');
             $user->save();
             // redirect
             Session::flash('message', 'Successfully updated user');
             return Redirect::to('users');
         }
     } else {
         // User is not logged in
         Session::flash('message', 'Please log in');
         return Redirect::to('/');
     }
 }
示例#26
0
 /**
  * Save projection
  * 
  * @return \Illuminate\Http\JsonResponse
  */
 public function save()
 {
     $input = \Input::except('_token');
     // Try to get proj4 from postgis
     if (empty($input['proj4_params'])) {
         try {
             $input['proj4_params'] = \DB::table('public.spatial_ref_sys')->where('srid', $input['srid'])->pluck('proj4text');
         } catch (\Exception $e) {
         }
     }
     // Validate map content
     $validator = \Validator::make($input, ['extent' => 'required|max:255']);
     // When validation fails
     if ($validator->fails()) {
         return response()->json(['errors' => $validator->messages()]);
     }
     // Load content
     if (empty($input['id'])) {
         $projection = new Projection();
     } else {
         $projection = Projection::find($input['id']);
     }
     // Save changes
     $input['extent'] = implode(' ', $input['extent']);
     $projection->fill($input);
     $projection->save();
     // Response
     return response()->json(['success' => 'Projection saved', 'redirect' => url('/admin/projections/list')]);
 }
示例#27
0
    public function dologin()
    {
        $rules = array('username' => 'required', 'password' => 'required');
        $message = array('required' => 'Data :attribute harus diisi', 'min' => 'Data :attribute minimal diisi :min karakter');
        $validator = Validator::make(Input::all(), $rules, $message);
        if ($validator->fails()) {
            return Redirect::to('/')->withErrors($validator)->withInput(Input::except('password'));
        } else {
            $data = array('username' => Input::get('username'), 'password' => Input::get('password'));
            if (Auth::attempt($data)) {
                $data = DB::table('user')->select('user_id', 'level_user', 'username')->where('username', '=', Input::get('username'))->first();
                //print_r($data);
                //echo $data->id_users;
                Session::put('user_id', $data->user_id);
                Session::put('level', $data->level_user);
                Session::put('username', $data->username);
                //print_r(Session::all());
                return Redirect::to("/admin/beranda");
            } else {
                Session::flash('messages', '
					<div class="alert alert-danger alert-dismissable" >
                    		<button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
                    		<strong>Peringatan...</strong><br>
                    			Username dan password belum terdaftar pada sistem !
                    		</div>
				');
                return Redirect::to('/')->withInput(Input::except('password'));
            }
        }
    }
示例#28
0
 public function edit($id)
 {
     if (Request::isMethod('post')) {
         $rules = array('status_id' => 'required');
         $validator = Validator::make(Input::all(), $rules);
         if ($validator->fails()) {
             return Redirect::to("admin/{$this->name}/{$id}/{$this->action}")->withErrors($validator)->withInput(Input::except(''));
         } else {
             $table = Order::find($id);
             $table->status_id = Input::get('status_id');
             if ($table->save()) {
                 $name = trans("name.{$this->name}");
                 return Redirect::to("admin/{$this->name}")->with('success', trans("message.{$this->action}", ['name' => $name]));
             }
             return Redirect::to("admin/{$this->name}")->with('error', trans('message.error'));
         }
     }
     $order = DB::table('orders as o')->join('users as u', 'o.user_id', '=', 'u.id')->join('order_status as os', 'o.status_id', '=', 'os.id')->join('orders_details as od', 'o.id', '=', 'od.order_id')->select('o.id', DB::raw('CONCAT(u.firstname, " ", u.lastname) AS fullname'), 'os.title', 'o.created_at', DB::raw('SUM(od.price) AS total'), 'o.comment', 'o.status_id')->where('o.id', $id)->first();
     $products = DB::table('products as p')->join('orders_details as od', 'p.id', '=', 'od.product_id')->join('orders as o', 'od.order_id', '=', 'o.id')->select('p.id', 'p.link', 'p.name', 'od.price', 'od.quantity', DB::raw('od.price * od.quantity AS total'))->where('o.id', $id)->orderBy('o.id', 'asc')->get();
     $ordersStatus = OrderStatus::all();
     foreach ($ordersStatus as $status) {
         $orderStatus[$status['id']] = $status['title'];
     }
     return View::make("admin.shop.order.edit", ['item' => $order, 'name' => $this->name, 'action' => $this->action, 'status' => $orderStatus, 'products' => $products]);
 }
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     // Declare the rules for the form validation
     $rules = array('name' => 'required');
     $getPermissions = Input::get('permissions');
     // Validate the inputs
     $validator = Validator::make(Input::all(), $rules);
     // Check if the form validates with success
     if ($validator->passes()) {
         // Get the inputs, with some exceptions
         $inputs = Input::except('csrf_token');
         $this->role->name = $inputs['name'];
         $this->role->save();
         // Save permissions
         $perms = $this->permission->get();
         if (count($perms)) {
             if (isset($getPermissions)) {
                 $this->role->perms()->sync($this->permission->preparePermissionsForSave($getPermissions));
             }
         }
         // Was the role created?
         if ($this->role->id) {
             // Redirect to the new role page
             return Redirect::to('admin/roles/' . $this->role->id . '/edit')->with('success', Lang::get('admin/roles/messages.create.success'));
         }
         // Redirect to the new role page
         return Redirect::to('admin/roles/create')->with('error', Lang::get('admin/roles/messages.create.error'));
         // Redirect to the role create page
         return Redirect::to('admin/roles/create')->withInput()->with('error', Lang::get('admin/roles/messages.' . $error));
     }
     // Form validation failed
     return Redirect::to('admin/roles/create')->withInput()->withErrors($validator);
 }
示例#30
0
 public function doLogin()
 {
     // validate the info, create rules for the inputs
     $rules = array('email' => 'required|email', 'password' => 'required|alphaNum|min:3');
     $messages = array('validation.required' => 'We need to know your e-mail address!', 'same' => 'The :attribute and :other must match.', 'size' => 'The :attribute must be exactly :size.', 'between' => 'The :attribute must be between :min - :max.', 'in' => 'The :attribute must be one of the following types: :values');
     // run the validation rules on the inputs from the form
     $validator = Validator::make(Input::all(), $rules, $messages);
     // if the validator fails, redirect back to the form
     if ($validator->fails()) {
         return Redirect::to('login')->withErrors($messages)->withInput(Input::except('password'));
         // send back the input (not the password) so that we can repopulate the form
     } else {
         // create our user data for the authentication
         $userdata = array('email' => Input::get('email'), 'password' => Input::get('password'));
         // attempt to do the login
         if (Auth::attempt($userdata)) {
             // validation successful!
             // redirect them to the secure section or whatever
             // return Redirect::to('secure');
             // for now we'll just echo success (even though echoing in a controller is bad)
             echo 'SUCCESS!';
         } else {
             // validation not successful, send back to form
             return Redirect::to('login');
         }
     }
 }