mercredi 18 janvier 2017

Laravel Default Registration Select box value not saving in Database

In Laravel I created a select box in my default registration but the value is not saving in the database.

here is my code

AuthController.php

public function __construct()
{
    $this->middleware($this->guestMiddleware(), ['except' => 'logout']);
}

/**
 * Get a validator for an incoming registration request.
 *
 * @param  array  $data
 * @return \Illuminate\Contracts\Validation\Validator
 */
protected function validator(array $data)
{
    return Validator::make($data, [
        'name' => 'required|max:255',
        'email' => 'required|email|max:255|unique:users',
        'password' => 'required|min:6|confirmed',
        'role' => 'required|max:255',
    ]);
}

/**
 * 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']),
        'role' => $data['role'],
    ]);
}
}

register.blade.php

<div class="form-group">
                        <label class="col-md-4 control-label">Role</label>

                        <div class="col-md-6">
                             
                            @if ($errors->has('role'))
                                <span class="help-block">
                                    <strong></strong>
                                </span>
                            @endif
                        </div>
                    </div>

Can someone please tell me what is my mistake and what to change. Thanks!



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2jaRwV5
via IFTTT

Aucun commentaire:

Enregistrer un commentaire