如何解决Illuminate\Routing\Exceptions\UrlGenerationException 缺少 [Route: products] [URI: products/delete/{id}] 的必需参数
这是我在Web.php
文件中的路线
我做错了什么?
Route::get('/products/delete/{id}',[ProductsController::class,'delete'])->name('products');
这是我的产品刀片文件
<a href="products/delete/{{$product->id}}">Delete</a>
这是我的产品控制器功能
public function delete($id)
{
$product=Product::find($id);
$product->delete();
return redirect()->route('products');
}
解决方法
我认为你应该使用
<input [owlDateTimeTrigger]="dt3" formControlName="endDate" class="txtquestion date-field"
[owlDateTime]="dt3" [readonly]="data.disable" [disabled]="data.disable">
<owl-date-time [pickerType]="'calendar'" [disabled]="data.disable" #dt3></owl-date-time>
或者重定向到任何其他路由,而不是重定向到相同的路由
,//Its working Correctly after changes in my Routs and paths and functions
//I change in my blade file
<a href="products/delete/{{$product->id}}">Delete</a>
//This is My route in the file of Web.php (i made change in my Route::get)
Route::get('products/delete/{id}',[ProductsController::class,'delete']);
//Here is My Product Controller Function (Made Litte changes)
public function delete($id)
{
$product=Product::findorfail($id);
if($product){
$product->delete();
return back()->with('deleted',"Record Deleted Successfully");
}else{
return back()->with('Error',"Record Not Found");
}
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。