【发布时间】:2022-01-26 05:28:54
【问题描述】:
我有这个要求
$marche = March::with('attribution')->get()->where('attribution.date_attribution', '2021');
如何格式化“attribution.date_attribution”以仅检索年份?
我尝试使用 Carbon::parse 但出现以下错误:
Could not parse 'attribution.date_attribution': Failed to parse time string (attribution.date_attribution) at position 0 (a): The timezone could not be found in the database
【问题讨论】:
-
attribution.date_attribution 的当前格式是什么?
-
它已经在归因模型中格式化:
protected $dates = ['deleted_at', 'date_attribution'];