axsor
axsor

Reputation: 470

How to store php classes into mysql enum?

I'm using laravel 5.5.19 and I'm trying to save the class of a polymorphic relationship like this:

$table->unsignedInteger('credenciable_id')->nullable();
$table->enum('credenciable_type', ["App\\Router", "App\\ATA", "App\\Antena"])->nullable(); 

But mysql enum is being created like this:

| credenciable_id   | int(10) unsigned                       | YES  | MUL | NULL    |                |
| credenciable_type | enum('AppRouter','AppATA','AppAntena') | YES  |     | NULL    |                |

I tried to change double quotes to single quotes and double strokes to single stroke but without results.

How can I store the PHP class name into enum of MySQL using Laravel migrations?

Upvotes: 1

Views: 98

Answers (1)

Abdulla Nilam
Abdulla Nilam

Reputation: 38609

Create Enum like this in your database migration file.

$table->enum('credenciable_type', ["Router", "ATA", "Antena"])->nullable()

Upvotes: 1

Related Questions