From 3d63783fb358b5a257ea2472322de0fd18a5023e Mon Sep 17 00:00:00 2001 From: gcazin Date: Fri, 15 Dec 2023 14:33:31 +0100 Subject: [PATCH 1/3] Add charset and collation method to Blueprint --- src/Illuminate/Database/Schema/Blueprint.php | 22 +++++++++++++++++++ .../DatabaseMySqlSchemaGrammarTest.php | 4 ++-- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/src/Illuminate/Database/Schema/Blueprint.php b/src/Illuminate/Database/Schema/Blueprint.php index 3e8eeab99b42..0082873701b9 100755 --- a/src/Illuminate/Database/Schema/Blueprint.php +++ b/src/Illuminate/Database/Schema/Blueprint.php @@ -291,6 +291,28 @@ public function create() return $this->addCommand('create'); } + /** + * Specify the charset that should be used for the table. + * + * @param string $charset + * @return void + */ + public function charset($charset) + { + $this->charset = $charset; + } + + /** + * Specify the collation that should be used for the table. + * + * @param string $collation + * @return void + */ + public function collation($collation) + { + $this->collation = $collation; + } + /** * Specify the storage engine that should be used for the table. * diff --git a/tests/Database/DatabaseMySqlSchemaGrammarTest.php b/tests/Database/DatabaseMySqlSchemaGrammarTest.php index cf0b3fa010a3..bbe69fb2d466 100755 --- a/tests/Database/DatabaseMySqlSchemaGrammarTest.php +++ b/tests/Database/DatabaseMySqlSchemaGrammarTest.php @@ -131,8 +131,8 @@ public function testCharsetCollationCreateTable() $blueprint->create(); $blueprint->increments('id'); $blueprint->string('email'); - $blueprint->charset = 'utf8mb4'; - $blueprint->collation = 'utf8mb4_unicode_ci'; + $blueprint->charset('utf8mb4'); + $blueprint->collation('utf8mb4_unicode_ci'); $conn = $this->getConnection(); $conn->shouldReceive('getConfig')->once()->with('engine')->andReturn(null); From 4005004b25e53f462be9dab1f84c9f7ea8e367fa Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Fri, 15 Dec 2023 08:04:26 -0600 Subject: [PATCH 2/3] formatting --- src/Illuminate/Database/Schema/Blueprint.php | 32 ++++++++++---------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/src/Illuminate/Database/Schema/Blueprint.php b/src/Illuminate/Database/Schema/Blueprint.php index 0082873701b9..a34995b5071f 100755 --- a/src/Illuminate/Database/Schema/Blueprint.php +++ b/src/Illuminate/Database/Schema/Blueprint.php @@ -292,47 +292,47 @@ public function create() } /** - * Specify the charset that should be used for the table. + * Specify the storage engine that should be used for the table. * - * @param string $charset + * @param string $engine * @return void */ - public function charset($charset) + public function engine($engine) { - $this->charset = $charset; + $this->engine = $engine; } /** - * Specify the collation that should be used for the table. + * Specify that the InnoDB storage engine should be used for the table (MySQL only). * - * @param string $collation + * @param string $engine * @return void */ - public function collation($collation) + public function innoDb() { - $this->collation = $collation; + $this->engine('InnoDB'); } /** - * Specify the storage engine that should be used for the table. + * Specify the character set that should be used for the table. * - * @param string $engine + * @param string $characterSet * @return void */ - public function engine($engine) + public function charset($characterSet) { - $this->engine = $engine; + $this->charset = $characterSet; } /** - * Specify that the InnoDB storage engine should be used for the table (MySQL only). + * Specify the collation that should be used for the table. * - * @param string $engine + * @param string $collation * @return void */ - public function innoDb() + public function collation($collation) { - $this->engine('InnoDB'); + $this->collation = $collation; } /** From 679f9cfb88b3a8b85944befd5592b3f2589cdacc Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Fri, 15 Dec 2023 08:04:48 -0600 Subject: [PATCH 3/3] rename var --- src/Illuminate/Database/Schema/Blueprint.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Illuminate/Database/Schema/Blueprint.php b/src/Illuminate/Database/Schema/Blueprint.php index a34995b5071f..26f6ee5c4a7a 100755 --- a/src/Illuminate/Database/Schema/Blueprint.php +++ b/src/Illuminate/Database/Schema/Blueprint.php @@ -316,12 +316,12 @@ public function innoDb() /** * Specify the character set that should be used for the table. * - * @param string $characterSet + * @param string $charset * @return void */ - public function charset($characterSet) + public function charset($charset) { - $this->charset = $characterSet; + $this->charset = $charset; } /**