How to condense multiple boolean colummns into one column in laravel?

1 week ago 3
ARTICLE AD BOX

So currently I want to build a badges system where users can get certain badges by doing tasks. Now, currently I am doing something akin to this for the actual mysql table:

Schema::create('user_badges', function (Blueprint $table) { $table->integer("user_id", true, true); $table->boolean("Badge1"); $table->boolean("Badge2"); $table->boolean("Badge3"); $table->boolean("Badge4"); $table->boolean("Badge5"); $table->boolean("Badge6"); $table->boolean("Badge7"); $table->boolean("Badge8"); });

As you can see, this can cause tons of columns with scaling, which could be cumbersome to manage. Is there a better method to handle these booleans (for example an array)?

(Note: I literally just made this table and haven't actually added functionally yet because I don't want to shoot myself in the foot later, so hence so little code.)

Read Entire Article