Last active
March 8, 2018 23:39
-
-
Save Kindari/9283167 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php namespace Acme\Database; | |
use Illuminate\Database\Schema\Blueprint as BaseBlueprint; | |
class Blueprint extends BaseBlueprint {} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php namespace Acme\Database; | |
use Illuminate\Database\MysqlConnection as BaseMysqlConnection; | |
use Illuminate\Database\Schema\MysqlBuilder; | |
class MysqlConnection extends BaseMysqlConnection | |
{ | |
/** | |
* Get a schema builder instance for the connection. | |
* | |
* @return \Illuminate\Database\Schema\MySqlBuilder | |
*/ | |
public function getSchemaBuilder() | |
{ | |
if (is_null($this->schemaGrammar)) { $this->useDefaultSchemaGrammar(); } | |
return new MySqlBuilder($this)->blueprintResolver(function($table, $callback) { | |
return Blueprint( $table, $callback ); // return our custom Blueprint class | |
}); | |
} | |
/** | |
* Get the default schema grammar instance. | |
* | |
* @return \Illuminate\Database\Schema\Grammars\MySqlGrammar | |
*/ | |
protected function getDefaultSchemaGrammar() | |
{ | |
return $this->withTablePrefix(new SchemaGrammar); // return our custom SchemaGrammer | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php namespace Acme\Database; | |
use Illuminate\Database\Schema\Grammars\MySqlGrammar | |
class SchemaGrammer extends MysqlGrammer | |
{ | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// This can (and most likely should) be in a Service Provider | |
App::bind('db.connection.mysql', 'Acme\Database\MysqlConnection'); |
i get the same issue here for Laravel 5.6, any update please, thank you.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I would like to extend my Laravel 5.5 (or 5.6) Blueprint class with custom method. Can you please update this Blueprint extension example, I can't get mine working. Something has changed over time or etc...
Also how to execute that in the migration php file?