ミドルウェアを使用してクライアントから送信された値をview側で表示させたいのですが
具体的な方法が思いつきません。。。
どなたかご教示頂けないでしょうか?
※追記
「ユーザー新規登録ページ」の名前フォームに入力された値を「ホームページ」で取得したいと考えました。
ミドルウェアを使用してどのようにデータを保管、取得すれば良いのかが分かりませんでした。
そもそもミドルウェアを使用するだけでは実装出来ずクッキーを使用して実装する
↑ここまできました。
クッキーを使用することが正解かどうかは分かりませんが自分で進めてみたいと思います。
web.php
Route::get('Login', 'UserController@Login')->name('Login'); Route::get('Signup', 'UserController@Signup')->name('Signup'); Route::get('Home', 'UserController@Home')->name('Home');
UserController.php
namespace App\Http\Controllers; use Illuminate\Http\Request; class UserController extends Controller { public function Login() { return view('Lessons.Login'); } public function Signup() { return view('Lessons.Signup'); } public function Home() { return view('Lessons.Home'); } }
Home.blade.php
<!DOCTYPE html> <html lang="ja"> <head> <meta charset="utf-8"> <title>home</title> <link rel="stylesheet" type="text/css" href="login.css" media="all" /> <style> .top-username { position: absolute; right: 120px; top: 18px; color: lightcoral; text-decoration: none; } .top-logout { position: absolute; right: 30px; top: 18px; color: lightcoral; text-decoration: none; } #form { background: #053352; background-image: -webkit-linear-gradient(top, #053352, Courier New); background-image: -moz-linear-gradient(top, #053352, Courier New); background-image: -ms-linear-gradient(top, #053352, Courier New); background-image: -o-linear-gradient(top, #053352, Courier New); background-image: linear-gradient(to bottom, #053352, Courier New); -webkit-border-radius: 6; -moz-border-radius: 6; border-radius: 6px; font-family: Courier New; color: #ffffff; font-size: 30px; padding: 20px 20px 20px 20px; text-decoration: none; text-align: center; } </style> </head> <body> <p><a class="top-username" href={{ route('Home')}}>Username</a></p> <p><a class="top-logout" href={{ route('Login')}}>Logout</a></p> <br> <br> <br> <br> <br> <br> <div id="form"> <p>Welcome!Your Home!</p> <form method="POST" action="/Home"> </form> </div> </body> </html>
Signup.blade.php
@extends('layouts.Loginapp') @section('title') SignUp @endsection @section('form') <p>Name</p> <p class="name"><input type="text" name="name" maxlength="32" autocomplete="OFF" /></p> <p>Mailaddress</p> <p class="mailaddress"><input type="text" name="mailaddress" maxlength="32" autocomplete="OFF" /></p> <p>Password</p> <p class="password"><input type="password" name="password" maxlength="32" autocomplete="OFF" /></p> <p>Confirm Password</p> <p class="Confirm password"><input type="password" name="Confirm password" maxlength="32" autocomplete="OFF" /></p> <p class="submit"><input type="submit" value="登録" class="top-username" href={{ route('Home')}}></p> @endsection
Loginapp.blade.php
<!DOCTYPE html> <html lang="ja"> <head> <meta charset="utf-8"> <title>@yield('title')</title> <link rel="stylesheet" type="text/css" href="login.css" media="all" /> <style> body, p, form, input { margin: 0 } .top-login { position: absolute; right: 120px; top: 18px; color: lightcoral; text-decoration: none; } .top-signup { position: absolute; right: 30px; top: 18px; color: lightcoral; text-decoration: none; } #form { width: 350px; margin: 30px auto; padding: 20px; border: 1px solid #555; } form p { font-size: 14px; } .form-title { font-size: 30px; text-align: center; margin-bottom: 20px; border-bottom: solid 3px #fff; " } .name { margin-bottom: 20px; } .mailaddress { margin-bottom: 20px; } .password { margin-bottom: 20px; } .confirm password { margin-bottom: 20px; } input[type="text"], input[type="password"] { width: 350px; padding: 4px; font-size: 14px; margin: 0 auto; } .submit { text-align: center; } /* skin */ #form { background: #053352; background-image: -webkit-linear-gradient(top, #053352, Courier New); background-image: -moz-linear-gradient(top, #053352, Courier New); background-image: -ms-linear-gradient(top, #053352, Courier New); background-image: -o-linear-gradient(top, #053352, Courier New); background-image: linear-gradient(to bottom, #053352, Courier New); -webkit-border-radius: 6; -moz-border-radius: 6; border-radius: 6px; font-family: Courier New; color: #ffffff; font-size: 20px; padding: 20px 20px 20px 20px; text-decoration: none; } .submit input { background: #f78181; background-image: -webkit-linear-gradient(top, #f78181, #f78181); background-image: -moz-linear-gradient(top, #f78181, #f78181); background-image: -ms-linear-gradient(top, #f78181, #f78181); background-image: -o-linear-gradient(top, #f78181, #f78181); background-image: linear-gradient(to bottom, #f78181, #f78181); -webkit-border-radius: 8; -moz-border-radius: 8; border-radius: 8px; -webkit-box-shadow: 1px 1px 3px #666666; -moz-box-shadow: 1px 1px 3px #666666; box-shadow: 1px 1px 3px #666666; font-family: Courier New; color: #ffffff; font-size: 16px; padding: 10px 20px 10px 20px; text-decoration: none; } .submit input:hover { background: #f5c7c7; background-image: -webkit-linear-gradient(top, #f5c7c7, #f5c7c7); background-image: -moz-linear-gradient(top, #f5c7c7, #f5c7c7); background-image: -ms-linear-gradient(top, #f5c7c7, #f5c7c7); background-image: -o-linear-gradient(top, #f5c7c7, #f5c7c7); background-image: linear-gradient(to bottom, #f5c7c7, #f5c7c7); text-decoration: none; } #form { background: #053352; background-image: -webkit-linear-gradient(top, #053352, Courier New); background-image: -moz-linear-gradient(top, #053352, Courier New); background-image: -ms-linear-gradient(top, #053352, Courier New); background-image: -o-linear-gradient(top, #053352, Courier New); background-image: linear-gradient(to bottom, #053352, Courier New); -webkit-border-radius: 6; -moz-border-radius: 6; border-radius: 6px; font-family: Courier New; color: #ffffff; font-size: 20px; padding: 20px 20px 20px 20px; text-decoration: none; } </style> </head> <body> <p><a class="top-login" href={{ route('Login')}}>Login</a></p> <p><a class="top-signup" href={{ route('Signup')}}>Sign up</a></p> <br> <br> <br> <br> <br> <br> <div id="form"> <p>@yield('title')</p> <form method="GET" action="/Home"> @yield('form') </form> </div> </body> </html>
回答1件
あなたの回答
tips
プレビュー