Laravel Schema has a command for ENUM equivalent to the table. What is the SET equivalent to the table?
相关问题
- Views base64 encoded blob in HTML with PHP
- Laravel Option Select - Default Issue
- PHP Recursively File Folder Scan Sorted by Modific
- Can php detect if javascript is on or not?
- Using similar_text and strpos together
Roman Nazarkin's method works almost perfectly however there is a small issue with table prefixes (which this method does not account for) it is simple however to make this suggestion work with table prefixes:
According to the Laravel API, I don't think it is possible to create a set using the Schema Builder.
Source: http://laravel.com/api/class-Illuminate.Database.Schema.Blueprint.html
Extending laravel database schema methods is not too hard. Like Roman wrote, instead of extending, you can as well update your
vendor/laravel/framework/src/Illuminate/Database/Schema/Grammers/MysqlGrammer.php
vendor/laravel/framework/src/Illuminate/Database/Schema/Blueprint.php
After this, terminate your server by pressing Ctrl + C. Then type php artisan serve to start the laravel.
Step 1. Extend default classes(add this code to your migration file after
use
sections):Step 2. Then, we need to change default grammar and blueprint classes to our custom:
This method will also work after
composer update
, because we did not edited any framework code.As of now Laravel Schema Builder does not support SET datatype for columns. So, here is an alternative solution until someone add those code to Laravel.
Step 1: Create the table, use ENUM instead of SET.
Step 2: Now change ENUM to SET.
If you have a better solution, then please let me know.