Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

iMsIdZz's avatar

Date of birth save as null

Hello, i am creating form and on my database my dob save as null help me for sort out this is my table

$table->date('dob');

here is my form

    <div class="form-group{{ $errors->has('dob') ? ' has-error' : '' }}">
                        <label class="col-md-4 control-label">Date of Birth</label>

                        <div class="col-md-6">
                            <input type="text" class="span2" id="dp1" name="dob" value="{{ old('dob') }}">

                            @if ($errors->has('dob'))
                                <span class="help-block">
                                    <strong>{{ $errors->first('dob') }}</strong>
                                </span>
                            @endif
                        </div>
                    </div> 

this is on my controller

    protected function validator(array $data)
{
    return Validator::make($data, [
        'username' => 'required|max:255|unique:users',
        'firstname' => 'required|max:255',
        'lastname' => 'required|max:255',
        'gender' => 'required',
        'dob' => 'required',
        'email' => 'required|email|max:255|unique:users',
        'password' => 'required|confirmed|min:6',
    ]);
}

/**
 * Create a new user instance after a valid registration.
 *
 * @param  array  $data
 * @return User
 */
protected function create(array $data)
{
    return User::create([
        'username' => $data['username'],
        'firstname' => $data['firstname'],
        'lastname' => $data['lastname'],
        'gender' => $data['gender'],
        'dob' => $data['dob'],
        'email' => $data['email'],
        'password' => bcrypt($data['password']),
    ]);
}
0 likes
2 replies
tykus's avatar

Is dob included in the $fillable property on the User model?

jekinney's avatar

Why pass arrays in oop? Objects are more effiecent.

Any case what data type in db? And I use carbon personally to ensure proper data set up with dates, times and timestamps. I suggest the same to ensure consistency and proper format and all the features that carbon provides.

Please or to participate in this conversation.