How to include a blade template in different directory?

你。 提交于 2019-12-24 07:15:57

问题


I was already trying to follow the documentation tutorial. But, I always get an error, and I don't know how to solve it

How can I include a blade template in a different directory?

Dashboard.blade.php = in folder views/admin Landingpage.blade.php = in folder views/admin/subpage


回答1:


The @include directive allows you to include a Blade view from within another view.

//resources/views/admin/dashboard.blade.php
@include('admin.dashboard')

//resources/views/admin/subpage/landingpage.blade.php
@include('admin.subpage.landingpage')

You can also pass data into the included views.

@include('admin.dashboard', ['user' => $user])


来源:https://stackoverflow.com/questions/55998128/how-to-include-a-blade-template-in-different-directory

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!