我正在使用laravel 5.4,我按序列号使用过滤器,我想在序列号未保存在数据库中时显示提示“无数据”,但是当我过滤数据时,序列号未保存到数据库中,页面未显示提示,
这是我的刀片。
@extends('layouts.master')
@section('content')
......................................
<div class="panel panel-default">
@if (!$instrumentType->instruments->isEmpty())
<table class="table">
@foreach ($instruments as $instrument)
<tr>
<td>
Serial Number : {{ $instrument->serial_number }}
@if($instrument->customer !== NULL)
<div class="text-muted"><i class="fa fa-hospital-o" aria-hidden="true"></i> {{ $instrument->customer->name }}</div>
@endif
@if($instrument->contractType !== NULL)
<div class="text-muted"><i class="fa fa-compress" aria-hidden="true"></i> {{ $instrument->contractType->name }}</div>
@endif
</td>
<td>
<div class="pull-right">
<a type="button" href="{{ route('instrument.edit', ['instrumentType' => $instrumentType->id, 'instrument' => $instrument->id]) }}"
class="btn btn-success ">
<i class="fa fa-pencil"></i> Edit
</a>
@if($instrument->customer == NULL || $instrument->contractType == NULL)
<a href="{{ route('instrument.destroy', ['instrumentType' => $instrumentType->id, 'instrument' => $instrument->id]) }}"
data-method="delete" data-confirm="" class="btn btn-danger">
<i class="fa fa-trash"></i> <span class="hidden-xs">Delete</span>
</a>
@endif
</div>
</td>
</tr>
@endforeach
</table>
<div class="paginator text-center">{{ $instruments->links() }}</div>
@else
<div class="panel-body">
<div class="alert alert-warning text-center">No data.</div>
</div>
@endif
</div>
@endsection
。
答案 0 :(得分:0)
您可以使用:
获取数组的数量count($instrumentType->instruments)
将此代码添加为您的声明:
@if(count($instrumentType->instruments))
//
@else
//
@endif