如何在Laravel中获得关系模型的当前页面标题?

时间:2020-03-16 11:08:24

标签: laravel eloquent laravel-6 laravel-6.2

我的数据库表中有一些字段,我想根据每一页显示onDrawOver()titledescription,请让我知道如何显示此内容。我的数据库字段名称为keywordsmetatitlemetadesc

这是我正在显示属性列表的控制器代码...

keyword

1 个答案:

答案 0 :(得分:0)

您可以通过以下方式进行操作:

 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));
 }