我将尝试帮助你翻译与Tinker有关的数据的内容。当运行代码时,出现了"Class 'App\Date' not found"的错误。我认为这是因为我没有使用正确的代码,但我不知道需要哪些代码。
我有两个模型:
Contact (app\Models\Contact.php)
Date (app\Models\Date.php)
Contact
public function dates(){
return $this->hasMany(Date::class);
}
Tinker
php artisan tinker
$test = App\Models\Contact::find(516);
$test返回一个用户。
如果我在此之后使用$test->dates,那么会出现错误,内容如下:
[Symfony\Component\Debug\Exception\FatalErrorException]Class 'App\Date' not found
return $this->hasMany(App\Models\Date, 'contact_id');
。 - Quynh NguyenApp\Models\Date::class
- aynber