Skip to content

Commit e40622f

Browse files
authored
chore: return Collection from timestamps methods (#55871)
This is so that additional modifiers can be applied to the timestamps after they are created, such as `->useCurrent()`.
1 parent f880ec2 commit e40622f

File tree

1 file changed

+17
-14
lines changed

1 file changed

+17
-14
lines changed

src/Illuminate/Database/Schema/Blueprint.php

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1239,13 +1239,14 @@ public function timestampTz($column, $precision = null)
12391239
* Add nullable creation and update timestamps to the table.
12401240
*
12411241
* @param int|null $precision
1242-
* @return void
1242+
* @return Illuminate\Support\Collection<int, \Illuminate\Database\Schema\ColumnDefinition>
12431243
*/
12441244
public function timestamps($precision = null)
12451245
{
1246-
$this->timestamp('created_at', $precision)->nullable();
1247-
1248-
$this->timestamp('updated_at', $precision)->nullable();
1246+
return new Collection([
1247+
$this->timestamp('created_at', $precision)->nullable(),
1248+
$this->timestamp('updated_at', $precision)->nullable(),
1249+
]);
12491250
}
12501251

12511252
/**
@@ -1254,37 +1255,39 @@ public function timestamps($precision = null)
12541255
* Alias for self::timestamps().
12551256
*
12561257
* @param int|null $precision
1257-
* @return void
1258+
* @return Illuminate\Support\Collection<int, \Illuminate\Database\Schema\ColumnDefinition>
12581259
*/
12591260
public function nullableTimestamps($precision = null)
12601261
{
1261-
$this->timestamps($precision);
1262+
return $this->timestamps($precision);
12621263
}
12631264

12641265
/**
12651266
* Add creation and update timestampTz columns to the table.
12661267
*
12671268
* @param int|null $precision
1268-
* @return void
1269+
* @return Illuminate\Support\Collection<int, \Illuminate\Database\Schema\ColumnDefinition>
12691270
*/
12701271
public function timestampsTz($precision = null)
12711272
{
1272-
$this->timestampTz('created_at', $precision)->nullable();
1273-
1274-
$this->timestampTz('updated_at', $precision)->nullable();
1273+
return new Collection([
1274+
$this->timestampTz('created_at', $precision)->nullable(),
1275+
$this->timestampTz('updated_at', $precision)->nullable(),
1276+
]);
12751277
}
12761278

12771279
/**
12781280
* Add creation and update datetime columns to the table.
12791281
*
12801282
* @param int|null $precision
1281-
* @return void
1283+
* @return Illuminate\Support\Collection<int, \Illuminate\Database\Schema\ColumnDefinition>
12821284
*/
12831285
public function datetimes($precision = null)
12841286
{
1285-
$this->datetime('created_at', $precision)->nullable();
1286-
1287-
$this->datetime('updated_at', $precision)->nullable();
1287+
return new Collection([
1288+
$this->datetime('created_at', $precision)->nullable(),
1289+
$this->datetime('updated_at', $precision)->nullable(),
1290+
]);
12881291
}
12891292

12901293
/**

0 commit comments

Comments
 (0)