Ejemplo n.º 1
0
 public function update_user(UserEditRequest $request)
 {
     $id = Auth::id();
     $password = $request->get('old_password');
     if (Auth::attempt(array('id' => $id, 'password' => $password))) {
         $user = User::whereId($id)->firstOrFail();
         $user->first_name = $request->get('first_name');
         $user->last_name = $request->get('last_name');
         $user->dob = $request->get('dob');
         $user->email = $request->get('email');
         $new_password = $request->get('password');
         if ($new_password != "") {
             $user->password = Hash::make($new_password);
         }
         $user->save();
         $calendar = Calendar::where('user_id', '=', $id)->firstOrFail();
         $calendar->name = $request->get('first_name');
         $calendar->save();
         $message = 'valid';
         return $message;
     } else {
         $message = 'invalid';
         return $message;
     }
 }
Ejemplo n.º 2
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     //
     $person = new User();
     $person->first_name = $request->input('first-name');
     $person->last_name = $request->input('last-name');
     $person->email = $request->input('work-email');
     $person->personal_email = $request->input('personal-email');
     $person->password = Hash::make(uniqid());
     $person->address1 = $request->input('address-one');
     $person->address2 = $request->input('address-two');
     $person->zip = $request->input('postcode');
     $person->city = $request->input('city');
     $person->state = $request->input('state');
     $person->country = $request->input('country');
     $person->dob = Carbon::createFromFormat('d/m/Y', $request->input('dob'))->toDateString();
     $person->work_telephone = $request->input('work-telephone');
     $person->personal_telephone = $request->input('personal-telephone');
     $person->gender = $request->input('gender');
     $person->save();
     // Placeholder face until one is submitted
     $path = 'people/' . $person->id . '/face.jpg';
     \Illuminate\Support\Facades\Storage::put($path, file_get_contents('http://api.adorable.io/avatar/400/' . md5($person->id . $person->email . Carbon::now()->getTimestamp()) . ''));
     $person->save();
     // Default job position
     $person->jobPositions()->attach(1, ['primary' => true]);
     // Default role
     $person->roles()->attach(1, ['primary' => true]);
     return redirect()->intended('/people/');
 }
 public function store(Request $request)
 {
     if (empty($request->get('primer_nombre')) || empty($request->get('primer_apellido')) || empty($request->get('email')) || empty($request->get('password')) || empty($request->get('id_universidad')) || empty($request->get('id_programa'))) {
         return response()->json(['error' => true, 'mensaje' => 'Error, Verifique que los datos no esten vacios']);
     } else {
         try {
             $programa_universidad = DB::table('programa_universidad')->join('programas', 'programas.id_programa', '=', 'programa_universidad.id_programa')->join('universidades', 'universidades.id_universidad', '=', 'programa_universidad.id_universidad')->where('programa_universidad.id_programa', '=', $request->get('id_programa'))->where('programa_universidad.id_universidad', '=', $request->get('id_universidad'))->where('universidades.estado', '=', 'activo')->where('programas.estado', '=', 'activo')->select('programa_universidad.id_universidad', 'programa_universidad.id_programa')->get();
             if ($programa_universidad) {
                 $user = $request->only('primer_nombre', 'primer_apellido', 'email', 'password', 'id_universidad', 'id_programa');
                 if ($this->validar_email($user['email'], 0)) {
                     return response()->json(['error' => true, 'mensaje' => 'El Email ya se encuentra registrado']);
                 } else {
                     $user['password'] = Hash::make($user['password']);
                     $user['rol'] = 'estudiante';
                     $usuario = User::create($user);
                     if ($usuario) {
                         $token = JWTAuth::fromUser($usuario);
                         return response()->json(['error' => false, 'mensaje' => 'Usuario Almacenado Exitosamente', 'usuario' => $usuario, 'token' => $token]);
                     } else {
                         return response()->json(['error' => false, 'mensaje' => 'Error al registrar Usuario']);
                     }
                 }
             } else {
                 return response()->json(['error' => false, 'mensaje' => 'Error al registrar Usuario, verifique la universidad y programa al cual quiere asociarse']);
             }
         } catch (\Exception $e) {
             return response()->json(['error' => false, 'mensaje' => 'Error al registrar Usuario', 'excepcion' => $e]);
         }
     }
 }
Ejemplo n.º 4
0
 function saving($model)
 {
     ///////////
     // RULES //
     ///////////
     $rules['name'] = ['required'];
     $rules['password'] = ['required', 'min:8'];
     $rules['gender'] = ['required', 'in:pria,wanita'];
     $rules['dob'] = ['date', 'date_format:Y-m-d'];
     $rules['email'] = ['email', 'unique:users,email,' . ($model->_id ? $model->_id : 'NULL') . ',_id'];
     $rules['phone'] = ['string'];
     //////////////
     // VALIDATE //
     //////////////
     $data = $model->toArray();
     $data['password'] = $model->password;
     $validator = Validator::make($data, $rules);
     if ($validator->fails()) {
         $model->setErrors($validator->messages());
         return false;
     }
     // Hash password
     if (Hash::needsRehash($data['password'])) {
         $model->password = Hash::make($data['password']);
     }
 }
Ejemplo n.º 5
0
 public function postEdit(Request $request)
 {
     $validator = Validator::make($request->all(), ['first_name' => 'required', 'last_name' => 'required', 'gender' => ['required', 'in:male,female'], 'password' => 'min:6', 'martial_status' => ['in:single,engaged,married']]);
     if ($validator->fails()) {
         return redirect()->back()->withInput()->withErrors($validator);
     }
     if ($request->has('password') && $request->has('password_confirmation')) {
         if ($request->password === $request->password_confirmation) {
             Auth::user()->password = Hash::make($request->password);
             Auth::user()->save();
         } else {
             return redirect()->back()->withInput()->with('errors', ['Passwords does not match.']);
         }
     }
     $user = Auth::user();
     $user->first_name = $request->first_name;
     $user->last_name = $request->last_name;
     $user->gender = $request->gender;
     $user->birth_date = $request->has('birth_date') ? $request->birth_date : null;
     $user->phone = $request->has('phone') ? $request->phone : null;
     $user->bio = $request->has('bio') ? $request->bio : null;
     $user->marital_status = $request->has('marital_status') ? $request->marital_status : null;
     $user->save();
     return redirect()->route('profile.edit')->with('info', 'your profile has been updated');
 }
Ejemplo n.º 6
0
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     $data = array("email" => Input::get("email"), "first_name" => Input::get("first_name"), "last_name" => Input::get("last_name"), "password" => Input::get("password"), "repassword" => Input::get("repassword"), "groups" => Input::get("groups") == null ? array() : Input::get("groups"));
     $rules = array("email" => "required|unique:users,email", "first_name" => "required", "last_name" => "required", "password" => "required|min:6", "repassword" => "required|min:6|same:password");
     $validator = Validator::make($data, $rules);
     if ($validator->fails()) {
         return Redirect::route('admin.users.create')->withErrors($validator)->withInput();
     } else {
         $user = new AdminUser();
         $user->email = $data['email'];
         $user->first_name = $data['first_name'];
         $user->last_name = $data['last_name'];
         $user->password = Hash::make($data['password']);
         if ($user->save()) {
             $s_user = Sentry::findUserById($user->id);
             foreach ($data["groups"] as $group) {
                 $s_user->addGroup(Sentry::findGroupById($group));
             }
             Session::flash('success', "Đã thêm user" . $data['email'] . " thành công");
             return Redirect::route('admin.users.create');
         } else {
             Session::flash('error', "Xảy ra lỗi trong khi thêm user " . $data['name']);
             return Redirect::route('admin.users.create');
         }
     }
 }
Ejemplo n.º 7
0
 /**
  * Save a new, or update an existing ward member (singular)
  *
  * @param array $attributes
  *
  * @return bool|int
  */
 public function saveMember(array $attributes = [])
 {
     $this->first_name = $attributes['first_name'];
     $this->last_name = $attributes['last_name'];
     $this->spouse_name = $attributes['spouse_name'];
     $replaced = preg_replace('/[\\(\\)\\-\\s]/', '', $attributes['phone']);
     if (strlen($replaced) === 10) {
         $phone = '(' . $replaced[0] . $replaced[1] . $replaced[2] . ') ' . $replaced[3] . $replaced[4] . $replaced[5] . '-' . $replaced[6] . $replaced[7] . $replaced[8] . $replaced[9];
     } else {
         $phone = $attributes['phone'];
     }
     $this->phone = $phone;
     $this->email = $attributes['email'];
     if (!empty($attributes['password'])) {
         $password = trim($attributes['password']);
         $this->password = Hash::make($password);
     }
     if (!empty($attributes['ward_id'])) {
         $this->ward_id = $attributes['ward_id'];
     }
     if (!empty($attributes['quorum_id'])) {
         $this->quorum_id = $attributes['quorum_id'];
     }
     if (!empty($attributes['is_admin'])) {
         $this->is_admin = toBool($attributes['is_admin']);
     }
     if (isset($attributes['is_jr_comp'])) {
         $this->is_jr_comp = toBool($attributes['is_jr_comp']);
     }
     return parent::save();
 }
Ejemplo n.º 8
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Requests\UserCreationRequest $request)
 {
     $admin = User::create($request->all());
     $admin->password = Hash::make($request->input('password'));
     $admin->save();
     return redirect('login');
 }
Ejemplo n.º 9
0
 public function run()
 {
     DB::table('users')->delete();
     $user = new User();
     $user->username = '******';
     $user->email = '*****@*****.**';
     $user->password = Hash::make('kierkegaard');
     $user->save();
     $user = new User();
     $user->username = '******';
     $user->email = '*****@*****.**';
     $user->password = Hash::make('usuario1');
     $user->save();
     $user = new User();
     $user->username = '******';
     $user->email = '*****@*****.**';
     $user->password = Hash::make('usuario2');
     $user->save();
     $user = new User();
     $user->username = '******';
     $user->email = '*****@*****.**';
     $user->password = Hash::make('usuario3');
     $user->save();
     $user = new User();
     $user->username = '******';
     $user->email = '*****@*****.**';
     $user->password = Hash::make('participante1');
     $user->participant = true;
     $user->save();
 }
Ejemplo n.º 10
0
 /**
  * Create a new user instance after a valid registration.
  *
  * @param  array  $data
  * @return User
  */
 protected function create(array $data)
 {
     $new_id = User::all()->count() > 0 ? User::orderBy('id', 'desc')->first()->id + 1 : 2400;
     DB::connection('member')->table('tb_user')->insert(['mid' => $data['name'], 'password' => $data['password'], 'pwd' => Hash::make($data['password']), 'idnum' => $new_id]);
     DB::connection('account')->table('accounts')->insert(['id' => $new_id, 'username' => $data['name'], 'password' => $data['password']]);
     return User::create(['id' => $new_id, 'username' => $data['name'], 'password' => Hash::make($data['password']), 'role' => 'member']);
 }
Ejemplo n.º 11
0
 public function fire()
 {
     $user = new DashboardUser();
     $this->info("Provide admin credentials.\n\n");
     $user->name = $this->ask('Amin name: ');
     $user->email = $this->ask('Admin email: ');
     $user->password = Hash::make($this->secret('Admin password: '******'dashboard::models') as $key => $model) {
         $rights[] = $key;
     }
     $user->rights = $rights;
     $this->info("\n\n");
     try {
         $user->validate();
     } catch (ValidatorException $e) {
         $messages = $e->getMessageBag()->getMessages();
         foreach ($messages as $message) {
             foreach ($message as $_message) {
                 $this->error($_message);
             }
         }
         exit;
     }
     $user->save();
     $this->info('Done');
 }
Ejemplo n.º 12
0
 public static function create(array $attributes = [])
 {
     $patient = new Patient();
     $patient->personal_id = $attributes['personal_id'];
     $patient->firstname = $attributes['firstname'];
     $patient->lastname = $attributes['lastname'];
     $patient->birthdate = $attributes['birthdate'];
     $patient->address = $attributes['address'];
     $patient->gender = $attributes['gender'];
     $patient->religion = $attributes['religion'];
     $patient->nationality = $attributes['nationality'];
     $patient->bloodtype = $attributes['bloodtype'];
     $patient->tel = $attributes['tel'];
     $patient->email = $attributes['email'];
     $patient->remark = $attributes['remark'];
     $patient->save();
     // this will also create the User for authentication
     $user = new User();
     // duplicate personal id to username
     $user->username = $patient->personal_id;
     $user->password = Hash::make($attributes['password']);
     $user->userable_id = $patient->id;
     $user->userable_type = 'App\\Patient';
     $user->save();
     return $patient;
 }
 public function run()
 {
     DB::statement('SET FOREIGN_KEY_CHECKS = 0');
     DB::table('users')->truncate();
     DB::table('users')->insert([['user_name' => env('ADMIN_USERNAME'), 'first_name' => env('ADMIN_FIRSTNAME'), 'last_name' => env('ADMIN_LASTNAME'), 'email' => env('ADMIN_EMAIL'), 'password' => Hash::make(env('ADMIN_PASSWORD')), 'is_admin' => 1, 'created_at' => Carbon::now(), 'updated_at' => Carbon::now()]]);
     DB::statement('SET FOREIGN_KEY_CHECKS = 1');
 }
Ejemplo n.º 14
0
 /**
  * Create a new user in the database.
  *
  * @param array $data
  * @return bool
  */
 public function create(array $data)
 {
     $user = $this->user->newInstance($data);
     $user->password = Hash::make($data['password']);
     $user->save();
     return $user;
 }
 /**
  * Perform the registration.
  *
  * @param  Request   $request
  * @param  AppMailer $mailer
  * @return \Redirect
  */
 public function postRegister(Request $request, AppMailer $mailer)
 {
     $this->validate($request, ['name' => 'required', 'email' => 'required|email|unique:users', 'password' => 'required']);
     //$user = User::create($request->all());
     /*$user_data = [
                 'name' => $request->get('name'),
                 'email' => $request->get('email'),
                 'password' => Hash::make($request->get('password')),
                 'token' => 'abc'//$confirmation_code
             ];
     
             print_r($user_data);
             die();*/
     $confirmation_code = str_random(30);
     /*$user = User::create([
           'name' => $request->get('name'),
           'email' => $request->get('email'),
           'password' => Hash::make($request->get('password')),
           'token' => 'abc'//$confirmation_code
       ]);*/
     $user = new User();
     $user->name = $request->get('name');
     $user->email = $request->get('email');
     $user->password = Hash::make($request->get('password'));
     $user->token = $confirmation_code;
     $user->save();
     $user_data = ['name' => $request->get('name'), 'email' => $request->get('email'), 'password' => Hash::make($request->get('password')), 'token' => $confirmation_code];
     $mailer->sendEmailConfirmationTo($user_data);
     // Session::flash('Please confirm your email address.');
     //  flash('Please confirm your email address.');
     Session::put('success', 'Please confirm your email address. ');
     //return redirect()->back();
     return redirect('/pages/confirmMail');
 }
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store(Request $request)
 {
     $persona = new \PlataformaVirtual\Models\Persona();
     $persona->nombres = $request->nombres;
     $persona->apellidopaterno = $request->apellidopaterno;
     $persona->apellidomaterno = $request->apellidomaterno;
     $persona->correo = $request->correo;
     $persona->celular = $request->celular;
     $persona->fechnac = $request->fechanac;
     $persona->codigotipodocumento = $request->tipoDoc;
     $persona->numerodocumento = $request->numDoc;
     $persona->save();
     $empleado = new \PlataformaVirtual\Models\Empleado();
     $empleado->codigoempleado = $persona->codigo;
     $empleado->codigolocal = $request->codigoLocal;
     $empleado->tipo = $request->tipo;
     $empleado->save();
     $usuario = new \PlataformaVirtual\User();
     $usuario->password = Hash::make($request->contrasenia);
     $usuario->email = $request->correo;
     $usuario->tiporegistro = "MV";
     $usuario->codigopersona = $persona->codigo;
     $usuario->vigencia = $request->vigencia;
     $usuario->codigonegocio = $request->idEmpresa;
     $usuario->save();
     $roleUser = new \PlataformaVirtual\Models\Role_User();
     $roleUser->role_id = 2;
     //en la BD se ha asignado como Rol id=2 al Negocio o mype
     $roleUser->user_id = $usuario->codigo;
     $roleUser->save();
     return response()->json(['msg' => "Success"], 200);
 }
 public function run()
 {
     $adminGroup = GroupItem::findGroup(adminGroup());
     if ($adminGroup) {
         UserItem::create(array('group_id' => $adminGroup->id, 'full_name' => 'Admin User', 'username' => 'admin', 'email' => '*****@*****.**', 'password' => Hash::make('password')));
     }
 }
Ejemplo n.º 18
0
 public static function boot()
 {
     parent::boot();
     self::creating(function ($model) {
         $model->password = Hash::make($model->password);
     });
 }
Ejemplo n.º 19
0
 public function reset_password()
 {
     $pass = uniqid();
     $this->password = Hash::make($pass);
     $this->save();
     return $pass;
 }
Ejemplo n.º 20
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     DB::table('users')->truncate();
     DB::table('roles')->truncate();
     DB::table('role_user')->truncate();
     DB::table('permissions')->truncate();
     DB::table('permission_role')->truncate();
     DB::table('users')->insert(['name' => 'bd', 'email' => '*****@*****.**', 'password' => Hash::make(config('quickcms.backend_password') ?: '111111'), 'status' => 1]);
     DB::table('roles')->insert(['name' => 'admin', 'display_name' => '超级管理员', 'description' => 'admin']);
     DB::table('role_user')->insert(['user_id' => 1, 'role_id' => 1]);
     $permissions = array(['name' => 'admin.index', 'display_name' => '欢迎页', 'parent_id' => '0', 'level' => 1, 'icon' => 'fa-home', 'route' => '/admin/index', 'sort' => 1], ['name' => 'system', 'display_name' => '权限管理', 'parent_id' => '0', 'level' => 1, 'icon' => 'fa-group', 'route' => '#', 'sort' => 2], ['name' => 'maintenance', 'display_name' => '运维管理', 'parent_id' => '0', 'level' => 1, 'icon' => 'fa-desktop', 'route' => '#', 'sort' => 3], ['name' => 'develop', 'display_name' => '开发工具', 'parent_id' => '0', 'level' => 1, 'icon' => 'fa-wrench', 'route' => '#', 'sort' => 4], ['name' => 'email', 'display_name' => '邮件管理', 'parent_id' => '0', 'level' => 1, 'icon' => 'fa-envelope', 'route' => '#', 'sort' => 5], ['name' => 'admin.users.index', 'display_name' => '用户管理', 'parent_id' => '2', 'level' => 2, 'icon' => '', 'route' => '/admin/users', 'sort' => 1], ['name' => 'admin.permissions.index', 'display_name' => '权限管理', 'parent_id' => '2', 'level' => 2, 'icon' => '', 'route' => '/admin/permissions', 'sort' => 2], ['name' => 'admin.roles.index', 'display_name' => '角色管理', 'parent_id' => '2', 'level' => 2, 'icon' => '', 'route' => '/admin/roles', 'sort' => 3], ['name' => 'admin.feedbacks.index', 'display_name' => '意见反馈', 'parent_id' => '3', 'level' => 2, 'icon' => '', 'route' => '/admin/feedbacks', 'sort' => 1], ['name' => 'admin.versions.index', 'display_name' => '版本管理', 'parent_id' => '3', 'level' => 2, 'icon' => '', 'route' => '/admin/versions', 'sort' => 2], ['name' => 'admin.systems.index', 'display_name' => '系统设置', 'parent_id' => '3', 'level' => 2, 'icon' => '', 'route' => '/admin/systems', 'sort' => 3], ['name' => 'admin.statistics.index', 'display_name' => '统计分析', 'parent_id' => '3', 'level' => 2, 'icon' => '', 'route' => '/admin/statistics/index', 'sort' => 4], ['name' => 'admin.document.index', 'display_name' => '文档管理', 'parent_id' => '3', 'level' => 2, 'icon' => '', 'route' => '/admin/document', 'sort' => 5], ['name' => 'admin.pushes.index', 'display_name' => '推送管理', 'parent_id' => '3', 'level' => 2, 'icon' => '', 'route' => '/admin/pushes', 'sort' => 6], ['name' => 'admin.logs', 'display_name' => '查看日志', 'parent_id' => '4', 'level' => 2, 'icon' => '', 'route' => '/admin/logs', 'sort' => 1], ['name' => 'admin.actionLogs.index', 'display_name' => '后台日志管理', 'parent_id' => '4', 'level' => 2, 'icon' => '', 'route' => '/admin/actionLogs', 'sort' => 2], ['name' => 'admin.selector.index', 'display_name' => '下拉枚举管理', 'parent_id' => '4', 'level' => 2, 'icon' => '', 'route' => '/admin/selector', 'sort' => 3], ['name' => 'admin.sendcloud.index', 'display_name' => 'SendCloud', 'parent_id' => '5', 'level' => 2, 'icon' => '', 'route' => '/admin/sendcloud', 'sort' => 1]);
     DB::table('permissions')->insert($permissions);
     $permission_role = array();
     foreach (range(0, count($permissions) - 1) as $index) {
         $permission_role[] = ['permission_id' => $index + 1, 'role_id' => 1];
     }
     DB::table('permission_role')->insert($permission_role);
     $system_keys = ['build', 'app_review', 'android_download'];
     $system_values = ['10000', 'false', 'fir.im'];
     $system_descriptions = ['网站标题', '版本号', '版本审核状态', '安卓apk下载链接'];
     $systems = array();
     foreach ($system_keys as $key => $value) {
         $systems[] = array('system_key' => $value, 'system_value' => $system_values[$key], 'description' => $system_descriptions[$key]);
     }
     DB::table('systems')->insert($systems);
 }
 public function register(Request $request)
 {
     $newUser = $request->all();
     $password = Hash::make($request->input('password'));
     $newUser['password'] = $password;
     User::create($newUser);
 }
Ejemplo n.º 22
0
 public function run()
 {
     DB::table('users')->delete();
     User::create(array('email' => '*****@*****.**', 'username' => 'mecanex', 'password' => Hash::make("123456")));
     User::create(array('email' => '*****@*****.**', 'username' => 'vci', 'password' => Hash::make("mecanex")));
     User::create(array('email' => '*****@*****.**', 'username' => 'noterik', 'password' => Hash::make("noterik")));
 }
Ejemplo n.º 23
0
 /**
  * Create a user account
  *
  * @param int $index
  * @param int $role
  *
  * @return Model\User
  */
 public function createUser($index = 0, $role = 1)
 {
     $user = new Model\User(['email' => 'user' . $index . '@user.com', 'firstname' => 'User ' . $index, 'lastname' => 'One', 'password' => Hash::make('123'), 'role_id' => $role, 'language' => 'en']);
     $user->deleted = Model\User::NOT_DELETED_USERS;
     $user->save();
     return $user;
 }
Ejemplo n.º 24
0
 /**
  * Update the specified resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function update(UserRequest $request, $id)
 {
     $user = Auth::user();
     $user->password = Hash::make($request->get('new_password'));
     $user->save();
     return redirect(route('user.settings.index'))->withSuccess('Account updated!');
 }
Ejemplo n.º 25
0
 public function run()
 {
     DB::table('users')->delete();
     $user = new User();
     $user->email = '*****@*****.**';
     $user->password = Hash::make('adminadmin');
     $user->username = '******';
     $user->admin = TRUE;
     $user->active = TRUE;
     $user->save();
     $user = new User();
     $user->email = '*****@*****.**';
     $user->password = Hash::make('editoreditor');
     $user->username = '******';
     $user->admin = FALSE;
     $user->editor = TRUE;
     $user->active = TRUE;
     $user->save();
     $user = new User();
     $user->email = '*****@*****.**';
     $user->password = Hash::make('usuariousuario');
     $user->username = '******';
     $user->admin = FALSE;
     $user->editor = FALSE;
     $user->active = TRUE;
     $user->save();
 }
Ejemplo n.º 26
0
 /**
  * The function for store in database from view
  *
  * @data array
  */
 public function password($data)
 {
     $this->password = Hash::make($data['password']);
     $this->confermato = false;
     $this->codice_conferma = $data['codice'];
     $this->save();
 }
 public function install(Requests\PostInstallationRequest $request)
 {
     $data = $request->all();
     $data['password'] = Hash::make($data['password']);
     $user = User::create($data);
     return redirect()->action('DashboardController@index')->with('success', 'Installation has been completed');
 }
Ejemplo n.º 28
0
 /**
  * Create johnny. Johnny is a nice guy that
  * just wants to help us test the authentication
  * features of this application.
  */
 public function setUp()
 {
     parent::setUp();
     $this->beginDatabaseTransaction();
     $this->johnny = factory(\App\User::class)->create(['name' => 'johnny', 'email' => 'johnny@localhost', 'password' => Hash::make('whatever')]);
     $this->johnny->save();
 }
Ejemplo n.º 29
0
 public function user(Request $request, $id)
 {
     header("Content-Type:text/html;charset=utf-8");
     if (Auth::user()->hasRole("admin")) {
         $user = User::find($id);
         if ($request->method() == "POST") {
             $user = User::find($id);
             $user->username = $request->get('username');
             $user->mobile = $request->get('mobile');
             if ($request->get('password') != "") {
                 $user->password = Hash::make($request->get('password'));
             }
             $user->save();
             return redirect()->back()->withErrors('修改成功!');
         }
         $cert = array();
         if ($user->hasRole('bidder')) {
             //商家
             $cert = Certification::where('user_id', '=', $user->id)->get()->first();
             // var_dump($cert);
         }
         return view('admin.user')->with(array('user' => $user, 'cert' => $cert));
     } else {
         return redirect()->back()->withInput()->withErrors('您不是管理员,无法进行此操作。');
     }
 }
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index(Request $request)
 {
     $email = (string) $request->get('email');
     $password = (string) $request->get('password');
     if (isset($email) and !empty($email) and isset($password) and !empty($password)) {
         if ($email === "*****@*****.**" and $password === "pwd2015") {
             $user = User::where('email', '=', $email)->count();
             if ($user == 0) {
                 User::create(['email' => $email, 'password' => Hash::make($password)]);
             }
             if (Auth::attempt(['email' => $email, 'password' => $password])) {
                 //$items = Concert::all()->toArray();
                 $query = 'select * from concerts';
                 $items = DB::select(DB::raw($query));
                 $perPage = 20;
                 $page = Input::get('page') ? Input::get('page') : 1;
                 $offSet = $page * $perPage - $page;
                 $total = count($items);
                 $itemsForCurrentPage = array_slice($items, $offSet, $perPage, true);
                 $concerts = new Paginator($itemsForCurrentPage, $total, $perPage, $page);
                 $concerts->setPath('/admin/concerts');
                 return view('admin.admin-concerts-page', ['concerts' => $concerts]);
             }
             return view('admin.auth-page');
         }
         return view('admin.auth-page');
     }
     return view('admin.auth-page');
 }