Guest User

Untitled

a guest
Mar 7th, 2018
285
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.48 KB | None | 0 0
  1. public function up()
  2. {
  3. Schema::table('users', function (Blueprint $table) {
  4. $table->string('username', 15)->unique()->after('id');
  5. $table->string('lastname', 15)->unique()->after('username');
  6. $table->string('firstname', 15)->unique()->after('lastname');
  7. $table->string('contact')->nullable()->after('email');
  8. $table->date('birthday')->after('contact');
  9. $table->tinyInteger('status')->default(1)->after('birthday');
  10. });
  11. }
  12.  
  13. /**
  14. * Reverse the migrations.
  15. *
  16. * @return void
  17. */
  18. public function down()
  19. {
  20. Schema::table('users', function (Blueprint $table) {
  21. $table->dropColumn('username');
  22. $table->dropColumn('lastname');
  23. $table->dropColumn('firstname');
  24. $table->dropColumn('contact');
  25. $table->dropColumn('birthday');
  26. $table->dropColumn('status');
  27. });
  28. }
  29.  
  30. public function up()
  31. {
  32. Schema::create('users', function (Blueprint $table) {
  33. $table->increments('id');
  34. $table->string('email')->unique();
  35. $table->string('password', 60);
  36. $table->rememberToken();
  37. $table->timestamps();
  38. });
  39. }
  40.  
  41. protected $username = 'username'; //choose username instead of email
  42. protected $redirectPath = '/dashboard'; //if successful login
  43. protected $loginPath = 'auth/login'; //if not login
  44. protected $redirectAfterLogout = 'auth/login'; //redirect after login
  45.  
  46. /**
  47. * Create a new authentication controller instance.
  48. *
  49. * @return void
  50. */
  51. public function __construct()
  52. {
  53. $this->middleware('guest', ['except' => 'getLogout']);
  54. }
  55.  
  56. /**
  57. * Get a validator for an incoming registration request.
  58. *
  59. * @param array $data
  60. * @return IlluminateContractsValidationValidator
  61. */
  62. protected function validator(array $data)
  63. {
  64. return Validator::make($data, [
  65. 'username' => 'required|min:8|max:16|unique:users',
  66. 'lastname' => 'required',
  67. 'firstname' => 'required',
  68. 'contact' => 'required',
  69. 'birthday' => 'date_format: Y-m-d',
  70. 'email' => 'required|email|max:255|unique:users',
  71. 'password' => 'required|confirmed|min:6',
  72. ]);
  73. }
  74.  
  75. /**
  76. * Create a new user instance after a valid registration.
  77. *
  78. * @param array $data
  79. * @return User
  80. */
  81. protected function create(array $data)
  82. {
  83.  
  84. //dd($data); -- I can get all the values here
  85.  
  86. // I added my own column in this part to save. Is it correct?
  87. return User::create([
  88. 'username' => $data['username'],
  89. 'lastname' => $data['lastname'],
  90. 'firstname' => $data['firstname'],
  91. 'birthday' => $data['birthday'],
  92. 'contact' => $data['contact'],
  93. 'email' => $data['email'],
  94. 'status' => 1,
  95. 'password' => bcrypt($data['password']),
  96. ]);
  97. }
  98.  
  99. mysql> select * from users G;
  100. *************************** 1. row ***************************
  101. id: 1
  102. username:
  103. lastname:
  104. firstname:
  105. email: myemail@gmail.com
  106. contact: NULL
  107. birthday: 0000-00-00
  108. status: 1
  109. password: $2y$10$3NkmqZaje4MKzheqPZKbhOIGD7ZlqYRfIP6DJZz4zb4gXVNvFsv2W
  110. remember_token: PCYczF2Y9ts97TvbDOLsiXO5hxkekkxysmMYuIdN5MsaIY8TnroEof6d2jVM
  111. created_at: 2015-09-17 06:56:43
  112. updated_at: 2015-09-17 07:00:35
  113. 1 row in set (0.00 sec)
  114.  
  115. ERROR:
  116. No query specified
  117.  
  118. protected $fillable = ['username', 'lastname', 'firstname', 'contact', 'email', 'birthday', 'status', 'password'];
Add Comment
Please, Sign In to add comment