A simplified models.php config is as following:
- With
timestamp enabled with customized fields
- With property constants generation
- With base files generation
- With
$hidden & $fillable in base files
<?php
return [
'*' => [
...
'timestamps' => [
'enabled' => true,
'fields' => [
'CREATED_AT' => 'create_time',
'UPDATED_AT' => 'update_time',
]
],
'base_files' => true,
'with_property_constants' => true,
'hidden_in_base_files' => true,
'fillable_in_base_files' => true,
],
];
The generated base models have the following consts and casts:
const CREATED_AT = 'create_time';
const UPDATED_AT = 'update_time';
...
protected $casts = [
...
self::CREATE_TIME => 'int',
self::UPDATE_TIME => 'int',
...
];
Property's CREATED_AT AND UPDATED_AT are right, since Eloquent's HasTimestamps traits ( \Illuminate\Database\Eloquent\Concerns\HasTimestamps) uses these two constants.
However, the generated $casts are with the wrong keys. The self::CREATE_TIME and self::UPDATE_TIME keys should be self::CREATED_AT and self::UPDATED_AT.
A simplified
models.phpconfig is as following:timestampenabled with customized fields$hidden&$fillablein base filesThe generated base models have the following consts and casts:
Property's
CREATED_ATANDUPDATED_ATare right, since Eloquent'sHasTimestampstraits (\Illuminate\Database\Eloquent\Concerns\HasTimestamps) uses these two constants.However, the generated
$castsare with the wrong keys. Theself::CREATE_TIMEandself::UPDATE_TIMEkeys should beself::CREATED_ATandself::UPDATED_AT.