【发布时间】:2020-03-16 11:08:24
【问题描述】:
我的数据库表中有一些字段,我想根据每个页面显示title、description 和keywords,请告诉我如何显示这个。我的数据库字段名称是metatitle,metadesc,keyword
这是我显示属性列表的控制器代码...
public function listtype($slug){
$prtype= Listing::whereHas('proType',function($q) use($slug){
$q->where('slug','like','%'.$slug.'%');
})->paginate(50);
return view('property-type',compact('prtype','title'));
}
【问题讨论】:
-
你的Listing模型有
metatitle,metadesc,keyword字段吗?? -
我想要这个
proType的标题,我可以很容易地从listing模型中得到标题。但我很难得到title fromporType` -
@sainitor 你可以使用
with()方法。
标签: laravel eloquent laravel-6 laravel-6.2