如何按ID显示刀片中的数据

时间:2019-09-12 05:31:16

标签: laravel laravel-5.8

我必须为我所在国家的学生宿舍建立一个网站,我为每个宿舍都有一个专门的页面,其中显示了所有照片和财产,但我不知道当我拥有宿舍时如何使用宿舍ID进行操作餐桌,如果有人可以帮助我,请! 谢谢大家

这是我的旅馆控制器代码:

class HostelDetailsController extends Controller
{
    public function index(Request $request,$detail_id)
    {

        // $id = $request->query($detail_id);
        $file_details = HostelDetails::all();

        $files = Attachment::get();
        return view('khabgah_details', compact(['file_details', 'files']));

    }
}

这是我的旅馆页面刀片代码:

@foreach($file_details as $file)
    <div class="card-title text-center">
        <div class="mt-4"></div>
        <i class="fa fa-home mt-4 text-center" style="font-size:45px;"></i>
        <h5 class="mt-3 text-center"> لیلیه نرگس  </h5>
        <h6 class="fa fa-phone"> شماره تماس: {{ $file->phone_number }} </h6>
    </div>
@endforeach

它没有显示任何错误消息,但是当我加载页面时,它在表中显示了我的所有记录

1 个答案:

答案 0 :(得分:1)

//You can get the id from the index page of the hostel
public function show($id)
{
    $details = Detail::where('hostel_id', '=', $id)->get();
    return view('HostelDetailPage',compact('details'));
}