I\'m learning laravel, and I\'m stuck on a simple process. I want the tables to be generated as UTF-8 but varchar and text fields are like latin-1.
Schema section in gui
Here is my solution
1.add public $charset;
in the laravel/database/schema/table.php under public $engine;
2.replace the function create in laravel/database/schema/grammars/mysql.php like this
public function create(Table $table, Fluent $command)
{
$columns = implode(', ', $this->columns($table));
// First we will generate the base table creation statement. Other than auto
// incrementing keys, no indexes will be created during the first creation
// of the table as they're added in separate commands.
$sql = 'CREATE TABLE '.$this->wrap($table).' ('.$columns.')';
if ( ! is_null($table->engine))
{
$sql .= ' ENGINE = '.$table->engine;
}
if ( ! is_null($table->charset))
{
$sql.="DEFAULT CHARSET=".$table->charset;
}
return $sql;
}
3.now you can set any charset in your migration php such as $table->charset='utf8';