Revisando el código de Laravel, vemos que no hay ninguna diferencia, nullableTimestamps()
llama a timestamps()
con los mismos parámetros de entrada, sin embargo yo utilizo timestamps()
, es más cortos y es una instrucción menos de código (aunque sabemos que esto es despreciable en términos de tiempo).
/**
* Add nullable creation and update timestamps to the table.
*
* @param int $precision
* @return void
*/
public function timestamps($precision = 0)
{
$this->timestamp('created_at', $precision)->nullable();
$this->timestamp('updated_at', $precision)->nullable();
}
/**
* Add nullable creation and update timestamps to the table.
*
* Alias for self::timestamps().
*
* @param int $precision
* @return void
*/
public function nullableTimestamps($precision = 0)
{
$this->timestamps($precision);
}
Para más información del código, revisa: https://github.com/laravel/framework/blob/5.7/src/Illuminate/Database/Schema/Blueprint.php#L953
Respondiendo a si existía alguna diferencia en versiones anteriores, la respuesta es sí, en Laravel 5.1 nullableTimestamps()
creaba campos que permitían valores null, mientras timestamps()
, no:
/**
* Add nullable creation and update timestamps to the table.
*
* @return void
*/
public function nullableTimestamps()
{
$this->timestamp('created_at')->nullable();
$this->timestamp('updated_at')->nullable();
}
/**
* Add creation and update timestamps to the table.
*
* @return void
*/
public function timestamps()
{
$this->timestamp('created_at');
$this->timestamp('updated_at');
}
Para más información de este código de Laravel 5.1: https://github.com/laravel/framework/blob/5.1/src/Illuminate/Database/Schema/Blueprint.php#L775