From ad17f86d75c251a1edb9d19cfc5ebf425d9e5eae Mon Sep 17 00:00:00 2001 From: gcazin Date: Fri, 15 Dec 2023 14:33:31 +0100 Subject: [PATCH] Add charset and collection 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 3e8eeab99b4..0082873701b 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 cf0b3fa010a..bbe69fb2d46 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);