laravelでルートとコントローラーを定義させてviewを呼び出して表示させたいのですが、5.3だとroutes.phpのディレクトリが違っていてrouteからコントローラーを呼ぶパスがよくわかりません。
ContactControllerからお問合せ画面のcontact.blade.phpを呼び出したいです。
ブラウザからプロジェクト名/public/routes.phpと入力したら画面が真っ白で表示されました。
routes.phpのパスが違うのではないかと思うのですが、どのように指定すればよろしいでしょうか?
よろしくお願いします。
プロジェクト名/public/routes.php
lang
1<?php 2Route::get('contact', 'ContactController@index'); 3Route::get('hello', 'HelloController@index'); 4//Route::get('/', 'WelcomeController@index'); 5Route::get('/', function () { 6 return view('welcome'); 7});
lang
1<?php 2 3namespace App\Http\Controllers; 4 5 6class Controller extends BaseController 7{ 8 use AuthorizesRequests, DispatchesJobs, ValidatesRequests; 9} 10class ContactController extends Controller { 11 12 public function index() 13 { echo 'hello'; 14 return view('contact'); 15 } 16} 17class HelloController extends Controller { 18 19 public function index() 20 { 21 echo "hello"; 22 } 23}
lang
1contact.blade.php 2<html> 3 <head> 4 </head> 5 <body> 6 <h1>お問合せ画面です</h1> 7 </body> 8</html>
回答1件
あなたの回答
tips
プレビュー