facebook twitter hatena line google mixi email

Php/laravel/laravel5/認証画面

提供: 初心者エンジニアの簡易メモ
移動: 案内検索

自動生成

$ php artisan make:auth
Created View: /var/www/laravel/laraveltest/resources/views/auth/login.blade.php
Created View: /var/www/laravel/laraveltest/resources/views/auth/register.blade.php
Created View: /var/www/laravel/laraveltest/resources/views/auth/passwords/email.blade.php
Created View: /var/www/laravel/laraveltest/resources/views/auth/passwords/reset.blade.php
Created View: /var/www/laravel/laraveltest/resources/views/auth/emails/password.blade.php
Created View: /var/www/laravel/laraveltest/resources/views/layouts/app.blade.php
Created View: /var/www/laravel/laraveltest/resources/views/home.blade.php
Created View: /var/www/laravel/laraveltest/resources/views/welcome.blade.php
Installed HomeController.

マイルグレーションでテーブル作成

$ php artisan migrate

以下ファイルが実行されます

$ vi database/migrations/2014_10_12_100000_create_password_resets_table.php
class CreatePasswordResetsTable extends Migration
{
   public function up()
   {
       Schema::create('password_resets', function (Blueprint $table) {
           $table->string('email')->index();
           $table->string('token')->index();
           $table->timestamp('created_at');
       });
   }
   public function down()
   {
       Schema::drop('password_resets');
   }
}

以下テーブルができた

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(60) 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 NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
 KEY `password_resets_email_index` (`email`),
 KEY `password_resets_token_index` (`token`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

ttp://localhost/homeにアクセスすればアカウント作成・ログイン・リマインダーが操作できるようになってる