ユーザ用ツール

サイト用ツール


サイドバー



最近の更新



Tag Cloud

タグ数量
9
10
1
3
1
2
17
7
1
1
4
13
4
1
2
309
1
9
2
7
21
5
1
31
3
3
1
6
1
1
46
1
3
3
1
1
1
1
1
1
33
46
7
9
10
8
10
3
21
2
9
2
2
6
9
1
1
6
12
4
3
3
2
1
8
2
4
1
6
30
2
12
5
3
1
1
2
3
2
1
3
4
3
3
4
2
2
1
1
2
1
2
1
2
1
27
2
1
3
2
2
1
1
2
3
17
5
9
1
1
2
16
2
6
1
2
12
1
3
1
1
4
11
1
6
4
2
7
1
3
3
13
1
4
1
1
10
3
1
17
3
1
5
1
2
1
1
2
9
2
2
3
2
1
3
1
3
1
2
2
2
1
2
6
1
4
3
5
1
3
1
3
3
2
1
1
30
1
3
3
1
1
1
5
5
1
36
2
4
2
1
2
2
3
1
1
1
4
1
2
1
3
1
1
1
2
5
2
5
2
1
1
1
5
3
2
4
4
1
2
2
25
1
1
3
4
1
1
2
1
1
2
1
1
1
1
2
1
1
1
1
1
19
7
1
5
1
1
3
1
2
1
1
2
1
1
1
1
1
1
2
1
1
2
1
1
1
1
1
1
1
4
2
1
1
2
2
2
1
1
2
1
1
12
1
1
1
1
1
1
1
1
1
1
1
1
1
11_php:02_framework:01_laravel:42_auth

42 Laravel 認証機能

make:auth

$ php artisan make:auth

app/User.php

app/User.phpが作成される。

<?php

namespace App;

use Illuminate\Notifications\Notifiable;
use Illuminate\Contracts\Auth\MustVerifyEmail;
use Illuminate\Foundation\Auth\User as Authenticatable;

class User extends \TCG\Voyager\Models\User
{
    use Notifiable;

    /**
     * The attributes that are mass assignable.
     *
     * @var array
     */
    protected $fillable = [
        'name', 'email', 'password',
    ];

    /**
     * The attributes that should be hidden for arrays.
     *
     * @var array
     */
    protected $hidden = [
        'password', 'remember_token',
    ];

    /**
     * The attributes that should be cast to native types.
     *
     * @var array
     */
    protected $casts = [
        'email_verified_at' => 'datetime',
    ];
}

route/web.php

web.phpが更新される。

下記が追加される

Auth::routes();

Route::get('/home', 'HomeController@index')->name('home');

app/Http/Controllers/HomeController.php

app/Http/Controllers/HomeController.phpが作成される。

app/Http/Controllers/HomeController.php

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;

class HomeController extends Controller
{
    /**
     * Create a new controller instance.
     *
     * @return void
     */
    public function __construct()
    {
        $this->middleware('auth');
    }

    /**
     * Show the application dashboard.
     *
     * @return \Illuminate\Contracts\Support\Renderable
     */
    public function index()
    {
        return view('home');
    }
}

app/Http/Controllers/Auth

┗app
  ┗Http
    ┗Controllers
      ┗Auth
        ┣ForgotPasswordController.php 
        ┣LoginController.php
        ┣RegisterController.php
        ┗ResetPasswordController.php

テンプレート追加

resources
  ┗views
    ┣auth
    ┃┣passwords
    ┃┃┣email.blade.php
    ┃┃┗reset.blade.php
    ┃┣login.blade.php
    ┃┗register.blade.php
    ┣layouts
    ┃┗app.blade.php
    ┗home.blade.php

Migrationが追加・実行される

┗database
  ┗migrations
    ┣2014_10_12_000000_create_users_table.php
    ┗2014_10_12_100000_create_password_resets_table.php
11_php/02_framework/01_laravel/42_auth.txt · 最終更新: 2020/01/17 22:13 by matsui

Yesterday:860 Today:894 Total:237507