```php public function destroy(Exam $exam) { $exam->delete(); return redirect()->route('exam.index'); } ``` ``` 5. 由於我們在migrations中有設定`$table->foreign('exam_id')->references('id')->on('exams')->onDelete('cascade');`,所以在刪除測驗,也會順便把相關聯的題目都一併刪除。 [](https://github.com/tad0616/exam56/commit/5880652b0548cab8db088b97c3e9989bfa9826e9)
進階搜尋