make migration php artisan make:migration add_birthdate_to_users_table
in the migration file add to the table $table->date('birth_date')
Run php artisan migrate
Adding date of birth to registration from calender using jQuery datepicker
In app.blade.php add this code to it
<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
<script>
jQuery(document).ready(function($) {
$('.datepicker').datepicker({
dateFormat: "dd-mm-yy"
});
});
</script>
Add birth date input to register.php
in the RegisterController.php add birth_date attributes like so
protected function validator(array $data)
{
return Validator::make($data, [
'name' => ['required', 'string', 'max:255'],
'email' => ['required', 'string', 'email', 'max:255', 'unique:users'],
'password' => ['required', 'string', 'min:8', 'confirmed'],
'birth_date'=> ['required', 'string'],
]);
}
/**
* Create a new user instance after a valid registration.
*
* @param array $data
* @return \App\Models\User
*/
protected function create(array $data)
{
return User::create([
'name' => $data['name'],
'email' => $data['email'],
'password' => Hash::make($data['password']),
'birth_date'=> $data['birth_date'],
]);
}