建立遷移檔案users和password_resets
php artisan make:migration create_users_table --create=users
php artisan make:migration create_password_resets_table --create=password_resets
遷移檔案存放目錄 根目錄下database/migrations/file.php 分別修改遷移檔案的up
遷移檔案使用:https://learnku.com/docs/laravel/5.5/migrations/1329
/2018_11_05_023518_create_users_table.php
Schema::create('users', function (Blueprint $table) {
$table->engine = 'InnoDB';
$table->increments('id');
$table->string('name')->comment('使用者名稱稱');
$table->string('email')->unique()->comment('使用者郵箱');
$table->string('password')->comment('密碼');
$table->string('remember_token',100)->nullable()->comment('認證');
$table->timestamps();
});
// 2018_11_05_024615_create_password_resets_table.php
Schema::create('password_resets', function (Blueprint $table) {
$table->increments('id');
$table->string('email')->unique()->comment('使用者郵箱');
$table->string('token');
$table->timestamps();
});
然後執行
php artisan migrate
或者手動建立
CREATE TABLE `users` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`name` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
`email` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
`password` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
`remember_token` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL,
`created_at` timestamp NULL DEFAULT NULL,
`updated_at` timestamp NULL DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `users_email_unique` (`email`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
CREATE TABLE `password_resets` (
`email` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
`token` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
`created_at` timestamp NULL DEFAULT NULL,
KEY `password_resets_email_index` (`email`),
KEY `password_resets_token_index` (`token`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
然後就可以訪問http://127.0.0.1:8081/register //認證