Ich bekomme diesen Fehler, der sagt, "Keine Abfrageergebnisse für das Modell [App \ dummy]." Ich glaube, das Problem liegt im Controller. Wenn Sie das Formular absenden, soll es die Funktion im Kommentar-Controller auslösen. Dieser Controller ist neu, ich glaube der Fehler ist hier drin. Damals hörte es auf zu arbeiten. Hier ist die Datei Comment:Warum erkennt Laravel mein Modell nicht?
<?php
namespace App\Http\Controllers;
use App\Dummy;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB; //this one is for sql builders
use App\Comments;
use Illuminate\Http\RedirectResponse;
use DateTime; //to create a new date object you need to include this namespace
class commentController extends Controller
{
public function store(Dummy $post){
$date = new DateTime();
$timestamp = $date->getTimestamp();
$id = $post->id;
$post->addComment(request('body'));
return view('post', compact('post', 'timestamp', 'id'));
}
}
Ich versuchte App \ Dummy Klein machen, so dass es App \ Attrappe war, aber immer noch hat es nicht funktioniert. Es gibt mir immer noch den Fehler.
Hier ist mein Dummy-Modell:
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class dummy extends Model
{
protected $guarded = [];
public function comments(){
return $this->hasMany(Comments::class, 'post_id');
}
public function addComment($body){
$this->comments()->create(compact('body'));
}
}
zeigen Sie Ihre Modelldatei hier –
@Kris Roofte Ich habe mein Dummy-Modell auf dem Hauptpost veröffentlicht. – Lami