如何获取 Laravel 中关系模型的当前页面标题?
How to get Current page Title of Relationship Model in Laravel?
我的数据库中有一些字段table,我想根据每个页面显示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'));
}
您可以通过以下方式进行:
public function listtype($slug){
$prtype= Listing::whereHas('proType',function($q) use($slug){
$q->where('slug','like','%'.$slug.'%');
})->with('proType')->paginate(50);
dd($prtype); /** for checking **/
return view('property-type',compact('prtype', $prtype));
}
我的数据库中有一些字段table,我想根据每个页面显示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'));
}
您可以通过以下方式进行:
public function listtype($slug){
$prtype= Listing::whereHas('proType',function($q) use($slug){
$q->where('slug','like','%'.$slug.'%');
})->with('proType')->paginate(50);
dd($prtype); /** for checking **/
return view('property-type',compact('prtype', $prtype));
}