Ich habe ein Problem mit Larave-Rahmenprogramm mit dem Löschen von CRUDS-Methode DELETE.Versuchen, Datensatz durch CRUD löschen route :: delete-Methode (Laravel 5.3)
Mein Weg Methode ist:
Route::delete('cats/{cat}/delete', function(Furbook\Cat $cat){
$cat->delete(); return redirect('cats.index')
->withSuccess('Cat
has been deleted.'); });
Meine Ansicht mit delete url:
@extends('layouts.master')
@section('header')
<a href="{{ url('/') }}">Back to the overview</a>
<h2>
{{ $cat->name }}
</h2>
<a href="{{ url('cats/'.$cat->id.'/edit') }}">
<span class = "glyphicon glyphicon-edit"></span>
Edit
</a>
<a href ="{{ url('cats/'.$cat->id.'/delete') }}">
<span class ="glyphicon glyphicon-trash"></span>
Delete
</a>
<p>Last edited: {{ $cat->updated_at }}</p>
@endsection
@section('content')
<p>Date of Birth: {{ $cat->date_of_birth }} </p>
<p>
@if ($cat->breed)
Breed:
{{ url('cats/breeds/'.$cat->breed->name) }}
@endif
</p>
@endsection
My Cat Modell:
<?php
namespace Furbook;
use Illuminate\Database\Eloquent\Model;
class Cat extends Model {
// We specified the fields that are fillable in the Cat model beforehand
protected $fillable = ['name','date_of_birth','breed_id'];
// informacja o tym, żeby nie uaktualniać update_at w tabeli kotów
public $timestamps = false;
public function breed(){
return $this->belongsTo('Furbook\Breed');
}
}
?>
Wenn ich auf löschen Link bin klicken, dort ist ein Fehler wie folgt:
MethodNotAllowedHttpException in RouteCollection.php Zeile 233:
Ich weiß nicht, was los ist. Könntest du mir helfen, das Problem zu lösen?
Könnte mir jemand bei diesem Problem helfen? Ich wäre sehr dankbar, Grüße.
'MethodNotAllowedHttpException' emittiert wird, wenn Sie eine Route zuzugreifen, die nicht hören für die Request-Methode aber nicht vorhanden Sie verwenden. Sie greifen nämlich über eine 'GET' Anfrage auf die' delete' Route zu. – apokryfos