我注意到,如果我扩展我的母版页 userdashboard.blade.php panel-body
或简单paragraph
变得可点击,并将我重定向到主页,如果我点击它。所以下面是我的母版页。
母版页
<!doctype html>
<html>
<head>
<title>@yield('title')</title>
<link rel = "stylesheet" href= "{{ URL::asset('css/bootstrap.min.css')}}">
</head>
<body>
@include ('layouts.includes.headeruser')
<div class = "container">
@include ('templates.alerts')
@yield ('content') {{-- @yield is always used to get content from a child page into master page. So this page will be master page. --}}
</div>
</body>
</html>
这是我的首页,这是我第一次扩展母版页。
welcomeuser
@extends('layouts.userdefault')
@section('title')
Welcome
@endsection
@section('content')
Welcome User
@endsection
这是我第二次扩展母版页,这是可点击的容器,不知道是什么原因。
userdashboard
@extends('layouts.userdefault')
@section('content')
<div class = "panel panel-default">
<div class = "panel-body">
<h1>Hello Welcome to Dashboard</h1>
</div>
</div>
@endsection
UserController中
public function index()
{
return view('welcomeuser');
}
public function getDashboard()
{
return view ('layouts.dashboard.userdashboard');
}
路由
//HOME
Route::get('/', [
'uses' => '\App\Http\Controllers\UserController@index',//Specify the name of the controller and the method name.
'as' => 'welcomeuser',
]);
// REDIRECT TO DASHBOARD IF LOGIN IS TRUE
Route::get('/dashboard',
[
'uses' => '\App\Http\Controllers\UserController@getDashboard',
'as' => 'layouts.dashboard.userdashboard',
'middleware' => 'auth',
]);