这是我在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');
}
答案 0 :(得分:0)
我认为你应该使用
<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>
或者重定向到任何其他路由,而不是重定向到相同的路由
答案 1 :(得分:0)
//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");
}
}