Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public function up()
- {
- Schema::table('users', function (Blueprint $table) {
- $table->string('username', 15)->unique()->after('id');
- $table->string('lastname', 15)->unique()->after('username');
- $table->string('firstname', 15)->unique()->after('lastname');
- $table->string('contact')->nullable()->after('email');
- $table->date('birthday')->after('contact');
- $table->tinyInteger('status')->default(1)->after('birthday');
- });
- }
- /**
- * Reverse the migrations.
- *
- * @return void
- */
- public function down()
- {
- Schema::table('users', function (Blueprint $table) {
- $table->dropColumn('username');
- $table->dropColumn('lastname');
- $table->dropColumn('firstname');
- $table->dropColumn('contact');
- $table->dropColumn('birthday');
- $table->dropColumn('status');
- });
- }
- public function up()
- {
- Schema::create('users', function (Blueprint $table) {
- $table->increments('id');
- $table->string('email')->unique();
- $table->string('password', 60);
- $table->rememberToken();
- $table->timestamps();
- });
- }
- protected $username = 'username'; //choose username instead of email
- protected $redirectPath = '/dashboard'; //if successful login
- protected $loginPath = 'auth/login'; //if not login
- protected $redirectAfterLogout = 'auth/login'; //redirect after login
- /**
- * Create a new authentication controller instance.
- *
- * @return void
- */
- public function __construct()
- {
- $this->middleware('guest', ['except' => 'getLogout']);
- }
- /**
- * Get a validator for an incoming registration request.
- *
- * @param array $data
- * @return IlluminateContractsValidationValidator
- */
- protected function validator(array $data)
- {
- return Validator::make($data, [
- 'username' => 'required|min:8|max:16|unique:users',
- 'lastname' => 'required',
- 'firstname' => 'required',
- 'contact' => 'required',
- 'birthday' => 'date_format: Y-m-d',
- '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)
- {
- //dd($data); -- I can get all the values here
- // I added my own column in this part to save. Is it correct?
- return User::create([
- 'username' => $data['username'],
- 'lastname' => $data['lastname'],
- 'firstname' => $data['firstname'],
- 'birthday' => $data['birthday'],
- 'contact' => $data['contact'],
- 'email' => $data['email'],
- 'status' => 1,
- 'password' => bcrypt($data['password']),
- ]);
- }
- mysql> select * from users G;
- *************************** 1. row ***************************
- id: 1
- username:
- lastname:
- firstname:
- email: myemail@gmail.com
- contact: NULL
- birthday: 0000-00-00
- status: 1
- password: $2y$10$3NkmqZaje4MKzheqPZKbhOIGD7ZlqYRfIP6DJZz4zb4gXVNvFsv2W
- remember_token: PCYczF2Y9ts97TvbDOLsiXO5hxkekkxysmMYuIdN5MsaIY8TnroEof6d2jVM
- created_at: 2015-09-17 06:56:43
- updated_at: 2015-09-17 07:00:35
- 1 row in set (0.00 sec)
- ERROR:
- No query specified
- protected $fillable = ['username', 'lastname', 'firstname', 'contact', 'email', 'birthday', 'status', 'password'];
Add Comment
Please, Sign In to add comment