How to handle enums in Laravel database

Suppose there are two models Patient and also Exam and the relationship between them is One To Many, I mean each patient can have many exams.

Patient Model
Exam Model

Each exam individually has some features, For example radiologists want to add the following information for each exam: Diagnosis (Pnemonia, Tuberculosis, Normal), Degree of severity (Severe, Moderate, Mild, Absent) and Level of normality of the exam (Typical or Atypical). The question is that what would the final structure of exam table in the database look like?

In the directory config I make a exams.php file which includes the following content that finally returns an array like:

Then in the migration file of table exams we can use enum type and refer to the config file exams.php and the related keys by dot notation like :


and the patients table looks like this:

After doing

php artisan migrate:fresh

The table exams in the database will have such structure like:

But before using enum I recommend you read this article.

Posting daily about Python, Laravel, Livewire, Nuclear Physicist PhD