缺少[Route:time.update][URI:time/{time}]所需的参数



我使用的是laravel 6。我在同一个应用程序中有类似的控制器,具有类似的视图,运行良好。即使将两者进行比较,仍然找不到错误。

FacadeIgnitionExceptionsViewException
Missing required parameters for [Route: time.update] [URI: time/{time}].
(View: C:xampphtdocscmsresourcesviewstimeslotedit.blade.php)
http://cms.test/time/4/edit
Error: return new static("Missing required parameters for [Route {$route->getName()}] [URI: {$route->uri()}].");

编辑链接:

<a href="{{route('time.edit',$timeslot->id)}}">{{$timeslot->timeslot_title}}</a>

控制器:

public function edit(Timeslot $timeslot){
return view('timeslot.edit',compact('timeslot'));
}
public function update(TimeslotRequest $request, Timeslot $timeslot){
$timeslot->update($request->all());
}

编辑表单:

@extends('layouts.admin')
@section('content')
<h1>Edit Timeslot  Details </h1>
<form action="{{route('time.update',$timeslot->id)}}" method="POST">
@method('PATCH')
@include('timeslot.form')
<button type="submit" class="btn btn-primary">Update Timeslot</button>
</form>
@endsection

route()第二个参数是关联数组。如果你通过一个模型,它可以自动获得时隙id。假设您的路线中的型号名称为"时间段"。

<a href="{{route('time.edit', ['timeslot' => $timeslot]}}">{{$timeslot->timeslot_title}}</a>

最新更新