mardi 28 mai 2019

Boolean Value cannot be stored in database (laravel)

so, i want to store a boolean value to database, but it always stored its default value (false). what i am doing is using Function Store as default

This is my UserController:

 public function store(Request $request)
{
     $request->validate([
        'name'      =>'required',
        'email'     =>'required',
        'is_active'     =>'required',
        'password'  => 'required|string|min:6|max:191|confirmed',
        'password_confirmation' => 'required|same:password',
    ]);
      $user = new User;
      $user->name     = $request->name;
      $user->email    = $request->email;
      $user->password = Hash::make($request->password);
    $user->save();

    return redirect()->route('users.index')->with('success','Users created successfully');
}

And this is my create form to submit:

 <form action="" method="POST">
              @csrf
              <div class="col-sm-9 form-left"> 
                <div class="form-group form-box">
                  <label for="name">Name</label>
                  <input type="text" class="form-control" id="name" name="name" placeholder="Name">
                </div>

                <div class="form-group form-box">
                  <label for="email">Email</label>
                  <input type="text" class="form-control" id="email" name="email" placeholder="Email">
                </div>

                <div class="form-group form-box">
                  <label for="password">Password</label>
                  <input type="password" class="form-control" id="password" name="password" placeholder="Password">
                </div>

                <div class="form-group form-box">
                  <label for="password_confirmation">Password Confirmation</label>
                  <input type="password" class="form-control" id="password_confirmation" name="password_confirmation" placeholder="Password Confirmation">
                </div>

              </div>

              <div class="col-sm-3 form-right"> 
               <div class="form-group form-box">
                  <label for="is_active">Status</label>
                  <div class="radio">
                    <label><input type="radio" name="is_active" id="is_active" value="0" checked> Not Verified</label>
                  </div>
                  <div class="radio">
                    <label><input type="radio" name="is_active" id="is_active" value="1" > Verified</label>
                  </div>
                </div>

                <button type="submit" class="btn btn-default">Save</button> 
              </div>

          </form>

Did i Miss something?



from Newest questions tagged laravel-5 - Stack Overflow http://bit.ly/2QsYRkm
via IFTTT

Aucun commentaire:

Enregistrer un commentaire