Last active
August 25, 2017 09:24
-
-
Save erorrorg/4f354d0376811f5ff77a7089f4e94346 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="{{ app()->getLocale() }}"> | |
<head> | |
<meta charset="utf-8"> | |
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | |
<meta name="viewport" content="width=device-width, initial-scale=1"> | |
<meta name="csrf-token" content="{{ csrf_token() }}"> | |
<title>PHP Laravel 5.4 AuthExample 01</title> | |
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta/css/bootstrap.min.css" integrity="sha384-/Y6pD6FV/Vv2HJnA6t+vslU6fwYXjCFtcEpHbNJ0lyAFsXTsjBbfaDjzALeQsN6M" crossorigin="anonymous"> | |
<link rel="stylesheet" href="{{ Request::root() }}/css/base.css"> | |
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.11.0/umd/popper.min.js" integrity="sha384-b/U6ypiBEHpOf/4+1nzFpr53nxSS+GLCkfwBdFNTxtclqqenISfwAzpKaMNFNmj4" crossorigin="anonymous"></script> | |
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta/js/bootstrap.min.js" integrity="sha384-h0AbiXch4ZDo7tp9hKZ4TsHbi047NrKGLO3SEJAg45jXxnGIfYzk4Si90RDIqNm1" crossorigin="anonymous"></script> | |
</head> | |
<body> | |
<nav class="navbar navbar-expand-lg navbar-dark bg-dark"> | |
<span class="navbar-brand pr-0 mr-0"> | |
<a class="navbar-brand pr-0 mr-0" href="{{ Request::root() }}">AuthExample</a> | |
:: | |
<a class="navbar-brand pr-0 mr-0" href="{{ route('user.top') }}">利用者</a> | |
</span> | |
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation"> | |
<span class="navbar-toggler-icon"></span> | |
</button> | |
<div class="collapse navbar-collapse" id="navbarSupportedContent"> | |
<ul class="navbar-nav mr-auto"></ul> | |
<ul class="navbar-nav"> | |
@if (Auth::guest('web')) | |
<li class="nav-item"> | |
<a class="nav-link" href="{{ route('user.register') }}">新規利用者登録</a> | |
</li> | |
<li class="nav-item"> | |
<a class="nav-link" href="{{ route('user.login') }}">利用者ログイン</a> | |
</li> | |
@else | |
<li class="nav-item"> | |
<a class="nav-link" href="{{ route('user.logout') }}">利用者ログアウト</a> | |
</li> | |
@endif | |
</ul> | |
</div> | |
</nav> | |
<div class="container"> | |
@yield('content') | |
</div> | |
<footer class="footer"> | |
<span>© 2017 Typo / </span><a class="link-footer" href="https://erorr.org/">erorr.org</a> | |
</footer> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
html { | |
position: relative; | |
min-height: 100%; | |
} | |
body { | |
margin-bottom: 60px; | |
} | |
.navbar { | |
margin-bottom: 20px; | |
} | |
.footer { | |
position: absolute; | |
bottom: 0; | |
width: 100%; | |
height: 60px; | |
line-height: 60px; | |
padding: 0 16px 0 16px; | |
background-color: #343a40; | |
color: white; | |
} | |
.link-footer:link, | |
.link-footer:visited { | |
color: white; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App\Http\Controllers\User; | |
use App\Http\Controllers\Controller; | |
use Illuminate\Foundation\Auth\SendsPasswordResetEmails; | |
use Illuminate\Http\Request; | |
class ForgotPasswordController extends Controller | |
{ | |
/* | |
|-------------------------------------------------------------------------- | |
| パスワードリセットコントローラ | |
|-------------------------------------------------------------------------- | |
| | |
| このコントローラはパスワードリセットメールの処理の責務を持ち、 | |
| アプリケーションからユーザへ通知を送るために役立つトレイトを | |
| 取り込む。自由にこのトレイトを調べてください。 | |
| | |
*/ | |
use SendsPasswordResetEmails; | |
/** | |
* 新しいコントローラインスタンスの生成 | |
* | |
* @return void | |
*/ | |
public function __construct() | |
{ | |
$this->middleware('guest'); | |
} | |
public function showLinkRequestForm() | |
{ | |
return view('user.password.request'); | |
} | |
protected function validateEmail(Request $request) | |
{ | |
$rule = [ | |
'email' => 'required|email' | |
]; | |
$messages = []; | |
$attributes = [ | |
'email' => 'メールアドレス', | |
]; | |
$this->validate( | |
$request, | |
$rule, | |
$messages, | |
$attributes | |
); | |
} | |
protected function sendResetLinkResponse($response) | |
{ | |
return view('user.password.sent'); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App\Exceptions; | |
use Exception; | |
use Illuminate\Auth\AuthenticationException; | |
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler; | |
class Handler extends ExceptionHandler | |
{ | |
/** | |
* レポートしない例外タイプのリスト | |
* | |
* @var array | |
*/ | |
protected $dontReport = [ | |
\Illuminate\Auth\AuthenticationException::class, | |
\Illuminate\Auth\Access\AuthorizationException::class, | |
\Symfony\Component\HttpKernel\Exception\HttpException::class, | |
\Illuminate\Database\Eloquent\ModelNotFoundException::class, | |
\Illuminate\Session\TokenMismatchException::class, | |
\Illuminate\Validation\ValidationException::class, | |
]; | |
/** | |
* 例外をレポート、もしくはログ | |
* | |
* ここはSentryやBugsnagなどに例外を送るために良い場所 | |
* | |
* @param \Exception $exception | |
* @return void | |
*/ | |
public function report(Exception $exception) | |
{ | |
parent::report($exception); | |
} | |
/** | |
* HTTPレスポンスに対応する例外をレンダー | |
* | |
* @param \Illuminate\Http\Request $request | |
* @param \Exception $exception | |
* @return \Illuminate\Http\Response | |
*/ | |
public function render($request, Exception $exception) | |
{ | |
return parent::render($request, $exception); | |
} | |
/** | |
* 認証例外を認証失敗レスポンスへ変換 | |
* | |
* @param \Illuminate\Http\Request $request | |
* @param \Illuminate\Auth\AuthenticationException $exception | |
* @return \Illuminate\Http\Response | |
*/ | |
protected function unauthenticated($request, AuthenticationException $exception) | |
{ | |
if ($request->expectsJson()) { | |
return response()->json(['error' => 'Unauthenticated.'], 401); | |
} | |
return redirect()->guest(route('user.login')); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@extends('layouts.base') | |
@section('content') | |
<span>{{ Auth::user()->name }}さん、こんにちは!</span> | |
@endsection |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App\Http\Controllers\User; | |
use Illuminate\Http\Request; | |
use App\Http\Controllers\Controller; | |
class HomeController extends Controller | |
{ | |
public function __construct() | |
{ | |
$this->middleware('auth')->except(['showTop']); | |
} | |
public function showTop() | |
{ | |
return view('user.top'); | |
} | |
public function showHome() | |
{ | |
return view('user.home'); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@extends('layouts.base') | |
@section('content') | |
@if ($errors->any()) | |
<div class="alert alert-danger" role="alert"> | |
<ul class="mb-0"> | |
@foreach ($errors->all() as $error) | |
<li>{{ $error }}</li> | |
@endforeach | |
</ul> | |
</div> | |
@endif | |
<div class="card"> | |
<div class="card-header"> | |
利用者ログイン | |
</div> | |
<div class="card-body"> | |
<form method="POST" action="{{ route('user.login') }}"> | |
{{ csrf_field() }} | |
<div class="form-group"> | |
<label for="email">メールアドレス</label> | |
<input type="text" class="form-control" id="email" name="email" value="{{ old('email') }}" placeholder="メールアドレス"> | |
</div> | |
<div class="form-group"> | |
<label for="password">パスワード</label> | |
<input type="password" class="form-control" id="password" name="password" placeholder="パスワード"> | |
</div> | |
<button type="submit" class="btn btn-primary">ログイン</button> | |
<div class="form-group mt-3"> | |
<a href="{{ route('user.password.request') }}">パスワードの初期化</a> | |
</div> | |
</form> | |
<hr> | |
<a class="btn btn-outline-primary" href="{{ route('user.register') }}" role="button">新規利用登録</a> | |
</div> | |
</div> | |
@endsection |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App\Http\Controllers\User; | |
use App\Http\Controllers\Controller; | |
use Illuminate\Foundation\Auth\AuthenticatesUsers; | |
use Illuminate\Http\Request; | |
class LoginController extends Controller | |
{ | |
/* | |
|-------------------------------------------------------------------------- | |
| ログインコントローラ | |
|-------------------------------------------------------------------------- | |
| | |
| このコントローラはアプリケーションの認証ユーザを処理し、 | |
| トップページへリダイレクトする。コントローラはアプリケーションに | |
| 機能を便利に提供するためにトレイトを使用している | |
| | |
*/ | |
use AuthenticatesUsers { | |
logout as traitLogout; | |
} | |
/** | |
* ログイン後のユーザリダイレクト先 | |
* | |
* @var string | |
*/ | |
protected $redirectTo = '/user/home'; | |
/** | |
* 新しいコントローラインスタンスの生成 | |
* | |
* @return void | |
*/ | |
public function __construct() | |
{ | |
$this->middleware('guest')->except(['logout']); | |
} | |
public function showLoginForm() | |
{ | |
return view('user.login'); | |
} | |
protected function validateLogin(Request $request) | |
{ | |
$rule = [ | |
$this->username() => 'required|string', | |
'password' => 'required|string', | |
]; | |
$messages = []; | |
$attributes = [ | |
'email' => 'メールアドレス', | |
'password' => 'パスワード', | |
]; | |
$this->validate( | |
$request, | |
$rule, | |
$messages, | |
$attributes | |
); | |
} | |
public function logout(Request $request) | |
{ | |
$this->traitLogout($request); | |
return redirect('user'); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<p>以下のURLをクリックし、パスワードの初期化を行って下さい。</p> | |
<p><a href='{{ $restUrl }}'>{{ $restUrl }}</a></p> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App\Http\Middleware; | |
use Closure; | |
use Illuminate\Support\Facades\Auth; | |
class RedirectIfAuthenticated | |
{ | |
/** | |
* 送られてきたリクエストの処理 | |
* | |
* @param \Illuminate\Http\Request $request | |
* @param \Closure $next | |
* @param string|null $guard | |
* @return mixed | |
*/ | |
public function handle($request, Closure $next, $guard = null) | |
{ | |
if (Auth::guard($guard)->check()) { | |
return redirect('/user/home'); | |
} | |
return $next($request); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@extends('layouts.base') | |
@section('content') | |
@if ($errors->any()) | |
<div class="alert alert-danger" role="alert"> | |
<ul class="mb-0"> | |
@foreach ($errors->all() as $error) | |
<li>{{ $error }}</li> | |
@endforeach | |
</ul> | |
</div> | |
@endif | |
<div class="card"> | |
<div class="card-header"> | |
新規利用者登録 | |
</div> | |
<div class="card-body"> | |
<form method="POST" action="{{ route('user.register') }}"> | |
{{ csrf_field() }} | |
<div class="form-group"> | |
<label for="name">アカウント名</label> | |
<input type="text" class="form-control" id="name" name="name" value="{{ old('name') }}" placeholder="アカウント名"> | |
</div> | |
<div class="form-group"> | |
<label for="email">メールアドレス</label> | |
<input type="text" class="form-control" id="email" name="email" value="{{ old('email') }}" placeholder="メールアドレス"> | |
</div> | |
<div class="form-group"> | |
<label for="password">パスワード</label> | |
<input type="password" class="form-control" id="password" name="password" placeholder="パスワード"> | |
<input type="password" class="form-control" id="password_confirmation" name="password_confirmation" placeholder="パスワード(確認)"> | |
</div> | |
<button type="submit" class="btn btn-primary">登録</button> | |
</form> | |
</div> | |
</div> | |
@endsection |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App\Http\Controllers\User; | |
use App\User; | |
use App\Http\Controllers\Controller; | |
use Illuminate\Support\Facades\Validator; | |
use Illuminate\Foundation\Auth\RegistersUsers; | |
class RegisterController extends Controller | |
{ | |
/* | |
|-------------------------------------------------------------------------- | |
| ユーザ登録コントローラ | |
|-------------------------------------------------------------------------- | |
| | |
| このコントローラは新しいユーザの登録、バリデーション、生成を処理する。 | |
| デフォルトで、このコントローラはトレイトを使用しており、これにより | |
| 他のコードを追加せずとも、この機能を提供している。 | |
| | |
*/ | |
use RegistersUsers; | |
/** | |
* 登録後のユーザリダイレクト先 | |
* | |
* @var string | |
*/ | |
protected $redirectTo = '/user/home'; | |
/** | |
* 新しいコントローラインスタンスの生成 | |
* | |
* @return void | |
*/ | |
public function __construct() | |
{ | |
$this->middleware('guest'); | |
} | |
/** | |
* 送られてきたユーザ登録リクエストのバリデター取得 | |
* | |
* @param array $data | |
* @return \Illuminate\Contracts\Validation\Validator | |
*/ | |
protected function validator(array $data) | |
{ | |
$validation = Validator::make($data, [ | |
'name' => 'required|string|max:255', | |
'email' => 'required|string|email|max:255|unique:users', | |
'password' => 'required|string|min:6|confirmed', | |
]); | |
$validation->setAttributeNames([ | |
'name' => 'アカウント名', | |
'email' => 'メールアドレス', | |
'password' => 'パスワード', | |
'password_confirmation' => 'パスワード(確認)', | |
]); | |
return $validation; | |
} | |
/** | |
* ユーザ登録成功後の新しいユーザインスタンス取得 | |
* | |
* @param array $data | |
* @return \App\User | |
*/ | |
protected function create(array $data) | |
{ | |
return User::create([ | |
'name' => $data['name'], | |
'email' => $data['email'], | |
'password' => bcrypt($data['password']), | |
]); | |
} | |
public function showRegistrationForm() | |
{ | |
return view('user.register'); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@extends('layouts.base') | |
@section('content') | |
@if ($errors->any()) | |
<div class="alert alert-danger" role="alert"> | |
<ul class="mb-0"> | |
@foreach ($errors->all() as $error) | |
<li>{{ $error }}</li> | |
@endforeach | |
</ul> | |
</div> | |
@endif | |
<div class="card"> | |
<div class="card-header"> | |
パスワード初期化のリクエスト | |
</div> | |
<div class="card-body"> | |
<form method="POST" action="{{ route('user.password.email') }}"> | |
{{ csrf_field() }} | |
<div class="form-group"> | |
<label for="email">メールアドレス</label> | |
<input type="text" class="form-control" id="email" name="email" value="{{ old('email') }}" placeholder="メールアドレス"> | |
</div> | |
<button type="submit" class="btn btn-primary">パスワード初期化URLをリクエスト</button> | |
</form> | |
</div> | |
</div> | |
@endsection |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@extends('layouts.base') | |
@section('content') | |
@if ($errors->any()) | |
<div class="alert alert-danger" role="alert"> | |
<ul class="mb-0"> | |
@foreach ($errors->all() as $error) | |
<li>{{ $error }}</li> | |
@endforeach | |
</ul> | |
</div> | |
@endif | |
<div class="card"> | |
<div class="card-header"> | |
パスワード初期化の実行 | |
</div> | |
<div class="card-body"> | |
<form method="POST" action="{{ route('user.password.reset', [$token]) }}"> | |
{{ csrf_field() }} | |
<input type="hidden" name="token" value="{{ $token }}"> | |
<div class="form-group"> | |
<label for="email">メールアドレス</label> | |
<input type="text" class="form-control" id="email" name="email" value="{{ old('email') }}" placeholder="メールアドレス"> | |
</div> | |
<div class="form-group"> | |
<label for="password">パスワード</label> | |
<input type="password" class="form-control" id="password" name="password" placeholder="新しいパスワード"> | |
<input type="password" class="form-control" id="password_confirmation" name="password_confirmation" placeholder="新しいパスワード(確認)"> | |
</div> | |
<button type="submit" class="btn btn-primary">パスワード初期化を実行</button> | |
</form> | |
</div> | |
</div> | |
@endsection |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App\Notifications\User; | |
use Illuminate\Bus\Queueable; | |
use Illuminate\Notifications\Notification; | |
use Illuminate\Contracts\Queue\ShouldQueue; | |
use Illuminate\Notifications\Messages\MailMessage; | |
class ResetPassword extends Notification | |
{ | |
use Queueable; | |
public $token; | |
/** | |
* Create a new notification instance. | |
* | |
* @return void | |
*/ | |
public function __construct($token) | |
{ | |
$this->token = $token; | |
} | |
/** | |
* Get the notification's delivery channels. | |
* | |
* @param mixed $notifiable | |
* @return array | |
*/ | |
public function via($notifiable) | |
{ | |
return ['mail']; | |
} | |
/** | |
* Get the mail representation of the notification. | |
* | |
* @param mixed $notifiable | |
* @return \Illuminate\Notifications\Messages\MailMessage | |
*/ | |
public function toMail($notifiable) | |
{ | |
return (new MailMessage) | |
->subject('パスワード初期化リクエストが行われました') | |
->from('webmaster@erorr.local') | |
->view('user.emails.password', [ | |
'restUrl' => route('user.password.reset', [ 'token' => $this->token]) | |
]); | |
} | |
/** | |
* Get the array representation of the notification. | |
* | |
* @param mixed $notifiable | |
* @return array | |
*/ | |
public function toArray($notifiable) | |
{ | |
return [ | |
// | |
]; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App\Http\Controllers\User; | |
use App\Http\Controllers\Controller; | |
use Illuminate\Foundation\Auth\ResetsPasswords; | |
use Illuminate\Http\Request; | |
class ResetPasswordController extends Controller | |
{ | |
/* | |
|-------------------------------------------------------------------------- | |
| パスワードリセットコントローラ | |
|-------------------------------------------------------------------------- | |
| | |
| このコントローラはパスワードリセットリクエストの処理に責任を持ち、その | |
| 振る舞いを取り込むために、シンプルなトレイトを使用しています。望み通りに | |
| 調整するため、このトレイトを使い、メソッドをオーバーライドしてください。 | |
| | |
*/ | |
use ResetsPasswords{ | |
reset as traitReset; | |
} | |
/** | |
* パスワードをリセットした後のユーザリダイレクト先 | |
* | |
* @var string | |
*/ | |
protected $redirectTo = '/user/password/successful'; | |
/** | |
* 新しいコントローラインスタンスの生成 | |
* | |
* @return void | |
*/ | |
public function __construct() | |
{ | |
$this->middleware('guest')->except(['showSuccessful']); | |
} | |
public function showResetForm(Request $request, $token = null) | |
{ | |
return view('user.password.reset')->with( | |
['token' => $token, 'email' => $request->email] | |
); | |
} | |
public function reset(Request $request) | |
{ | |
$attributes = [ | |
'email' => 'メールアドレス', | |
'password' => '新しいパスワード', | |
'password_confirmation' => '新しいパスワード(確認)', | |
]; | |
$this->validate( | |
$request, | |
$this->rules(), | |
$this->validationErrorMessages(), | |
$attributes | |
); | |
return $this->traitReset($request); | |
} | |
protected function sendResetResponse($response) | |
{ | |
return redirect($this->redirectPath()) | |
->with('status', trans($response)) | |
->with('reset', true); | |
} | |
public function showSuccessful() | |
{ | |
if(session('reset') !== true){ | |
abort(500); | |
} | |
return view('user.password.successful'); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@extends('layouts.base') | |
@section('content') | |
<span>メールを送信しました</span> | |
@endsection |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@extends('layouts.base') | |
@section('content') | |
<div> | |
<span>パスワード初期化が完了しました</span> | |
</div> | |
<div> | |
<a href="{{ route('user.home') }}">Homeへ移動</a> | |
</div> | |
@endsection |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@extends('layouts.base') | |
@section('content') | |
<span>利用者向けサイトトップ</span> | |
@endsection |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App; | |
use Illuminate\Notifications\Notifiable; | |
use Illuminate\Foundation\Auth\User as Authenticatable; | |
use App\Notifications\User\ResetPassword; | |
class User extends Authenticatable | |
{ | |
use Notifiable; | |
/** | |
* 複数代入を行う属性 | |
* | |
* @var array | |
*/ | |
protected $fillable = [ | |
'name', 'email', 'password', | |
]; | |
/** | |
* 配列には含めない属性 | |
* | |
* @var array | |
*/ | |
protected $hidden = [ | |
'password', 'remember_token', | |
]; | |
public function sendPasswordResetNotification($token) | |
{ | |
$this->notify(new ResetPassword($token)); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
|-------------------------------------------------------------------------- | |
| Webルート | |
|-------------------------------------------------------------------------- | |
| | |
| ここでアプリケーションのWebルートを登録できます。"web"ルートは | |
| ミドルウェアのグループの中へ、RouteServiceProviderによりロード | |
| contains the "web" middleware group. Now create something great! | |
| | |
*/ | |
Route::get('/', function () { | |
return ""; | |
}); | |
//利用者向けサービストップ | |
$this->get('user', 'User\HomeController@showTop')->name('user.top'); | |
//新規利用者登録 | |
$this->get('user/register', 'User\RegisterController@showRegistrationForm')->name('user.register'); | |
$this->post('user/register', 'User\RegisterController@register'); | |
//ログイン・ログアウト | |
$this->get('user/login', 'User\LoginController@showLoginForm')->name('user.login'); | |
$this->post('user/login', 'User\LoginController@login'); | |
$this->get('user/logout', 'User\LoginController@logout')->name('user.logout'); | |
//利用者ホーム | |
$this->get('user/home', 'User\HomeController@showHome')->name('user.home'); | |
//パスワード初期化 | |
$this->get('user/password/reset', 'User\ForgotPasswordController@showLinkRequestForm')->name('user.password.request'); | |
$this->post('user/password/email', 'User\ForgotPasswordController@sendResetLinkEmail')->name('user.password.email'); | |
$this->get('user/password/reset/{token}', 'User\ResetPasswordController@showResetForm')->name('user.password.reset'); | |
$this->post('user/password/reset/{token}', 'User\ResetPasswordController@reset'); | |
$this->get('user/password/successful', 'User\ResetPasswordController@showSuccessful')->name('user.password.successful'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment