0
由於型號名稱的更改,我的類Student
現在不能正常工作。 與數據庫名爲assos
:Laravel 5 belongsTo(classname :: class)不起作用
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`name` text COLLATE utf8mb4_unicode_ci NOT NULL,
`student_id` text COLLATE utf8mb4_unicode_ci NOT NULL,
`created_at` timestamp NULL DEFAULT NULL,
`updated_at` timestamp NULL DEFAULT NULL,
與模型Asso
鏈接,
查詢App\Asso::first()->belongsTo(Student::class)
返回null
當App\Asso::first()->belongsTo('App\Student','student_id')
返回相關的學生查詢。
我不明白爲什麼belongsTo(Student::class)
無法正常工作。你能幫我弄清楚嗎?
非常感謝
不要擔心關係的使用。這只是爲了說明這篇文章:)非常感謝! –