我正在尝试将菜单与_actualWork
分开。为什么以下内容不起作用?
app.blade.php
:
views/layouts/app.blade.php
<body>
@yield('menu')
<div class="container">
@yield('content')
</div>
</body>
:
views/layouts/menu.blade.php
答案 0 :(得分:2)
您不必yield
菜单部分,而是include
。正如您从official documentation中所读到的:
Blade的@include指令允许您从另一个视图中包含Blade视图。父视图可用的所有变量都将对包含的视图可用:
<div>
@include('shared.errors')
<form>
<!-- Form Contents -->
</form>
</div>
因此,您的layouts/app.blade.php
文件应如下所示:
<body>
@include('layouts.menu')
<div class="container">
@yield('content')
</div>
</body>
答案 1 :(得分:2)
您的app.blade.php应该看起来像这样
查找:views / layouts / app.blade.php
@Entity
public class Building {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
private String name;
private String description;
@OneToMany(mappedBy = "building", fetch = FetchType.EAGER, cascade = CascadeType.ALL, orphanRemoval = true)
private List<Photo> photos;
@ManyToMany(cascade = CascadeType.ALL)
@JoinTable(name = "category_building",
joinColumns = {@JoinColumn(name = "building_id")},
inverseJoinColumns = {@JoinColumn(name = "category_id")
})
private List<Category> categories;
public Building() {
}
public Building(String name, String description) {
this.name = name;
this.description = description;
}
public Building(String name, String description, List<Photo> photos) {
this.name = name;
this.description = description;
this.photos = photos;
}
public Building(String name, String description, List<Photo> photos, List<Category> categories) {
this.name = name;
this.description = description;
this.photos = photos;
this.categories = categories;
}
}
@Entity
public class Photo {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@ManyToOne(fetch = FetchType.EAGER, cascade = CascadeType.ALL)
@JoinColumn(name = "building_id")
private Building building;
@Column(name = "original_size")
byte[] originalSize;
@Column(name = "small_size")
byte[] smallSize;
@Column(name = "middle_size")
byte[] middleSize;
@Column(name = "large_size")
byte[] largeSize;
public Photo() {
}
public Photo(Building building, byte[] originalSize) {
this.building = building;
this.originalSize = originalSize;
}
和您的menu.blade.php
查找:views / layouts / menu.blade.php
<body>
@include('layouts.menu')
<div class="container">
@yield('content')
</div>
</body>