I'm trying to use Route Model Binding for Simple CRUD but Update And Delete Function Not Working. and I'm Using laravel 5.5
Route::resource('admin/file','AdminController');
My View For Edit and Delete Buttons
<a href="{{ route('file.edit', ['id'=>$file->id]) }}">
<form action="{{ route('file.destroy', ['id'=>$file->id]) }}" method="post">
{{method_field('DELETE')}}
{{csrf_field()}}
<button type="submit" class="delete">delete</button>
</form>
My Resource Controller :
namespace AppHttpControllers;
use AppFiles;
use IlluminateHttpRequest;
Store Work Fine
public function store(Request $request)
{
$this->validate($request,[
'title'=>'required',
'body'=>'required',
'price'=>'required',
'linkFile'=>'required',
]);
Files::create($request->all());
return redirect(route('file.index'));
}
But Edit and Delete Not Working
public function edit(Files $files)
{
return view('admin.edit',compact('files'))->with('title','Edit File');
}
public function destroy(Files $files)
{
$files->delete();
return redirect(route('file.index'));
}
My Model:
protected $table='files';
protected $fillable=[
'title','body','price','linkFile'
];
When I Delete Button Nothing Happens and Edit as Same
If I Add dd($files)
at First Column for Edit and Delete Function Then Response Will be []
and There's No Error for handle
Here My Route Lists
Anyone Can help Please?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…