What is the MySQL datatype SET equivalent in Laravel Schema?

前端 未结 6 1851
春和景丽
春和景丽 2020-12-15 10:13

Laravel Schema has a command for ENUM equivalent to the table. What is the SET equivalent to the table?

6条回答
  •  既然无缘
    2020-12-15 10:49

    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

    /**
     * Create the column definition for an set type.
     *
     * @param  \Illuminate\Support\Fluent  $column
     * @return string
    */
    protected function typeSet(Fluent $column){
        return "set('".implode("', '", $column->allowed)."')";
    }

    vendor/laravel/framework/src/Illuminate/Database/Schema/Blueprint.php

    /**
         * Create a new set column on the table.
         *
         * @param  string  $column
         * @param  array   $allowed
         * @return \Illuminate\Support\Fluent
        */
        public function set($column, array $allowed){
            return $this->addColumn('set', $column, compact('allowed'));
        }

    After this, terminate your server by pressing Ctrl + C. Then type php artisan serve to start the laravel.

提交回复
热议问题