1º
导航到:laravel/vendor/laravel/framework/src/Illuminate/Database/Schema
打开:Blueprint.php
寻找:
public function increments($column)
{
return $this->unsignedInteger($column, true);
}
在此之后添加:
/**
* Create a new auto-incrementing tiny integer column on the table.
*
* @param string $column
* @return \Illuminate\Support\Fluent
*/
public function incrementsTinyInteger($column)
{
return $this->unsignedTinyInteger($column, true);
}
/**
* Create a new auto-incrementing small integer column on the table.
*
* @param string $column
* @return \Illuminate\Support\Fluent
*/
public function incrementsSmallInteger($column)
{
return $this->unsignedSmallInteger($column, true);
}
/**
* Create a new auto-incrementing medium integer column on the table.
*
* @param string $column
* @return \Illuminate\Support\Fluent
*/
public function incrementsMediumInteger($column)
{
return $this->unsignedMediumInteger($column, true);
}
寻找:
public function unsignedInteger($column, $autoIncrement = false)
{
return $this->integer($column, $autoIncrement, true);
}
在此之后添加:
/**
* Create a new unsigned tiny integer column on the table.
*
* @param string $column
* @param bool $autoIncrement
* @param bool $unsigned
* @return \Illuminate\Support\Fluent
*/
public function unsignedTinyInteger($column, $autoIncrement = false)
{
return $this->tinyInteger($column, $autoIncrement, true);
}
/**
* Create a new unsigned small integer column on the table.
*
* @param string $column
* @param bool $autoIncrement
* @param bool $unsigned
* @return \Illuminate\Support\Fluent
*/
public function unsignedSmallInteger($column, $autoIncrement = false)
{
return $this->smallInteger($column, $autoIncrement, true);
}
/**
* Create a new unsigned medium integer column on the table.
*
* @param string $column
* @param bool $autoIncrement
* @param bool $unsigned
* @return \Illuminate\Support\Fluent
*/
public function unsignedMediumInteger($column, $autoIncrement = false)
{
return $this->mediumInteger($column, $autoIncrement, true);
}
2º
导航到:laravel/vendor/laravel/framework/src/Illuminate/Database/Schema/ Grammars
打开:MySqlGrammar.php
寻找:protected $serials = array('bigInteger', 'integer');
改成:protected $serials = array('bigInteger', 'integer', 'tinyInteger', 'smallInteger', 'mediumInteger');
3º
另外,在上面的同一个文件中,找到:
protected function typeTinyInteger(Fluent $column)
{
return 'tinyint(1)';
}
改成:
protected function typeTinyInteger(Fluent $column)
{
return 'tinyint';
}
如果有人知道如何扩展此文件并在 laravel 中配置用法,并想分享操作方法,我将不胜感激。但我不知道如何在扩展这些文件后配置一切,这就是我知道如何在 laravel 中执行此操作的方式。