How to see table fields from foreign keys in Laravel

后端 未结 3 807
小蘑菇
小蘑菇 2021-01-26 10:04

I\'m new at Laravel and not good with syntax. I want to see the values of another table through the foreign key(id of that table).

https://ibb.co/pXRFRHn You can see in

3条回答
  •  情话喂你
    2021-01-26 10:50

    All you have to do is

    data-myclassid="{{$cat->class_id}}"
    

    rather than this try this

    data-myclassid="{{ \Illuminate\Support\Facades\DB::table('class')->where('id',$cat->class_id)->value('name')}}"
    

    I am assuming that your table name is class as you want to show class name so in that database class name (column name) would be simple 'name' , that why I put name in value field....

提交回复
热议问题