asare847 / laravel_birth_date

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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'],
    ]);
}

About


Languages

Language:PHP 67.4%Language:Blade 31.6%Language:Shell 0.6%Language:Vue 0.4%