【发布时间】:2016-12-26 13:54:27
【问题描述】:
我正在拼命地尝试对 SQL 请求进行排序:
我希望每一行的日期属性都小于实际日期。
这是我正在做的事情:
$student = User::find($id)->student;
$extras = $student->extras->where('find', 1)
->where('date', '<', Carbon::now()->toDateString());
它返回一个空集合。这很奇怪,因为$student->extras->where('find', 1) 返回这个:
Collection {#229 ▼
#items: array:1 [▼
0 => Extra {#236 ▼
#fillable: array:10 [▶]
#connection: null
#table: null
#primaryKey: "id"
#keyType: "int"
#perPage: 15
+incrementing: true
+timestamps: true
#attributes: array:14 [▼
"id" => 4
"broadcast" => 0
"type" => "Cuisine"
"date" => "2016-06-15"
"date_time" => "13:00:00"
"duration" => 2
"salary" => 500
"benefits" => "test2"
"requirements" => "test2"
"informations" => ""
"find" => 1
"professional_id" => 2
"created_at" => "2016-08-19 08:18:59"
"updated_at" => "2016-08-19 08:18:59"
]
如您所见,日期远小于返回此值的Carbon::now()->toDateString():
2016-08-19
任何想法我做错了什么?
【问题讨论】:
标签: sql laravel eloquent php-carbon