【发布时间】:2023-03-10 20:53:01
【问题描述】:
这是我的 empcontroller.blade.php
* Display the specified resource.
*
* @param \App\employee $employee
* @return \Illuminate\Http\Response
*/
public function show(employee $employee)
{
$employees = employee::all();
return view ('emps.show',compact('employees'))->with('i');
}
这是我的 show.blade.php
@extends('emps.layout')
@section('content')
<div class="row">
<div class="col-sm-12 col-md-12 col-xs-12">
<div class="pull-right">
<a href="{{route('emps.index')}}">Back</a>
</div>
</div>
<table class="table table-borderd table-hover">
<tr>
<th>Name:</th>
<th>Age:</th>
<th>Mobile no:</th>
<th>Departmetn:</th>
<th>State:</th>
</tr>
@foreach ($employees as $employee)
<tr>
<td>{{++$i}}</td>
<td>{{$employee->name}} </td>
<td>{{$employee->age}}</td>
<td>{{$employee->mobile}} </td>
<td>{{$employee->department}}</td>
<td>{{$employee->state}}</td>
</tr>
@endforeach
</table>
</div>
</div>
@endsection
这是我的 route.web
Route::resource('emps', 'empcontroller');
这是我的 index.blade.php
<div class="pull-left">
<a href="{{route('emps.create')}}">Add New product</a>
<a href="{{route('emps.show')}}">show employees</a>
</div>
当我点击显示员工时抛出此错误 [Route: emps.show] [URI: emps/{emp}] 缺少必需的参数。 (查看:D:\xampp\htdocs\crud1\resources\views\emps\index.blade.php)
【问题讨论】: