如果查询在数据库中没有匹配项,我希望得到“未找到”结果。
这是我的result.blade.php:
@extends('layouts.app')
@section('content')
@foreach ($result as $object)
<div class="container pb-5">
<div class="row justify-content-center">
<div class="col-md-8">
<div class="card">
<div class="card-header">
<h3>Details for the animal</h3>
</div>
<div class="card-body">
<div class="col-12">
<p><strong>Serial Number: </strong>{{ $object->reference }}</p>
<p><strong>Animal Type: </strong>{{ $object->animal->type->category }}</p>
<p><strong>Farm: </strong>{{ $object->animal->user->name }}</p>
<p><strong>Date Of Birth: </strong>{{ $object->animal->dateOfBirth }}</p>
<p><strong>Farm Location: </strong>{{ $object->animal->user->address->city }}</p>
<p><strong>Clinic: </strong>{{ $object->animal->clinic->user->name ?? 'Was Not Checked by a Clinic' }}</p>
<p><strong>Clinic Location: </strong>{{ $object->animal->clinic->user->address->city }}</p>
<p><strong>Vaccination: </strong>
{{ $object->animal->clinic->vaccine1 ?? 'N/A' }},
{{ …Run Code Online (Sandbox Code Playgroud)