Laravel Timestamp而不是Carbon

时间:2018-04-02 07:53:48

标签: php laravel php-carbon

在简单模型中,有标准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}}

时,为什么我没有获得碳值

欢迎任何帮助(我想我只想念一小部分......)

0 个答案:

没有答案