Skip to content
Advertisement

Laravel database, what data type should I use to store a passport number?

I’m in the process of developing a Client Registration page for a travel agent. The client needs to save the passport number as a record in the MySQL database. I would like to know the data type ideal for mentioning in the migrations page for storing a Passport number. Usually, a passport number contains one or two English Letters and a few digits.

Schema::create('clients', function (Blueprint $table) {
    $table->id();
    $table->string('surname');
    $table->string('other_names')
    $table->date('dob');
    $table-> ?? ('ppt_no');

Advertisement

Answer

You should really encrypt them before the application goes into production. Otherwise, you probably want an alphanumeric column, like CHAR(9) or VARCHAR(9).

$table->string('passport_number', 9)->unique();
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement