【发布时间】:2017-09-02 09:41:03
【问题描述】:
很难解释我的问题。我希望你能理解它。
对于我的项目,我有一个主布局,其中包含内容的标题和产量。
master.blade.php
@include('partials.header')
<div class="container-fluid main-con">
@yield('content')
@include('partials.footer')
</div>
现在在主要公共路线上,我正在研究一种方法。
Web.php
Route::get('/', [
'uses' => 'ProductContoller@getIndex',
'as' => 'product.mainCats'
]);
ProductContoller.php
class ProductContoller extends Controller
{
public function getIndex(){
$ad_cats = Mainaddtype::orderBy('title')->get();
return view( 'shop.main-categories-page', ['mediacats' => $ad_cats]);
}
}
现在我的查询是,'main-categories-page' 在 master 的内容部分产生。但我也想在标题中使用相同的 Mainadtype 数据。所以我想在同一个函数上返回标题视图。如果你理解,请帮忙。
我现在正在尝试的是,
public function getIndex(){
$ad_cats = Mainaddtype::orderBy('title')->get();
return view( 'shop.main-categories-page', ['mediacats' => $ad_cats]);
return view( 'partials.header', ['mediacats' => $ad_cats]);
}
但我知道我们不能以这种方式返回。 提前致谢。
【问题讨论】:
标签: php laravel blade laravel-routing