我有一份报告,我在屏幕上出现。
report.blade.php
<html>
<head>
</head>
<body>
@yield('content')
</body>
</html>
report_sub1.blade.php
@extends('reports.report')
@section('content')
<h1> This is sub section 1 </h1>
<h1> This is sub section 2 </h1>
@stop
我想在第一个报告中包含第2部分,但在第二部分报告中不包括第2部分。 含义我有两个相同的报告,但不应打印第2部分。
你怎么能这样做?
答案 0 :(得分:2)
您可以将report.blade.php
用作母版页。然后使用两个部分作为子部分,并使用第三个部分作为section 1
。最后,只在您需要的地方包括最后一部分:
<强> section1.php 强>
<!-- section 1 definition-->
<h1> This is sub section 1 </h1>
<强> report_sub1.blade.php 强>
@extends('reports.report')
@section('content')
<!-- section 1 included -->
@include('section1')
<!-- section 2 included only here-->
<h1> This is sub section 2 </h1>
@stop
<强> report_sub2.blade.php 强>
@extends('reports.report')
@section('content')
<!-- section 1 included -->
@include('section1')
<!-- section 2 included is not included here-->
@stop