在简单模型中,有标准created_at
和自定义字段material_copied_at
在Blade $model->created_at
中返回Carbon值。 material_copied_at
返回INT
我在模型中定义了$date
class ImportRequestForQuote extends Model
{
const STATUS_NEW = 'new';
const STATUS_MATERIALCOPIED = 'materialCopied';
public $table = 'import_request_for_quotes';
protected $dates = ['material_copied_at'];
public $fillable = [
'client_id', 'number', 'num_items', 'material_copied_from', 'material_copied_at'
];
/**
* The attributes that should be casted to native types.
*
* @var array
*/
protected $casts = [
'client_id' => 'integer',
'number' => 'string',
'num_items' => 'integer',
'material_copied_from' => 'integer',
'material_copied_at' => 'timestamp'
];
public function items()
{
return $this->hasMany(ImportRequestForQuoteItem::class);
}
public function materialCopiedFrom()
{
return $this->belongsTo(User::class, 'material_copied_from');
}
}
当我使用{{ $model->material_created_at}}
欢迎任何帮助(我想我只想念一小部分......)