Perluas MySqlGrammar
kelas, misalnya di app/MySqlGrammar.php
:
namespace App;
use Illuminate\Support\Fluent;
class MySqlGrammar extends \Illuminate\Database\Schema\Grammars\MySqlGrammar {
protected function typeRealBinary(Fluent $column) {
return "binary({$column->length})";
}
}
Kemudian gunakan makro untuk menambahkan jenis kolom Anda sendiri:
DB::connection()->setSchemaGrammar(new \App\MySqlGrammar());
Blueprint::macro('realBinary', function($column, $length) {
return $this->addColumn('realBinary', $column, compact('length'));
});
Schema::create('table', function(Blueprint $table) {
$table->realBinary('url_hash', 16);
});