動作しない「」雄弁を比較し、私は必死にSQL要求を並べ替えしようとしている:日付は、メソッドが
私は日付属性が実際の日付より小さいすべての行を持っていると思います。ここで
は私がやっているものです:
$student = User::find($id)->student;
$extras = $student->extras->where('find', 1)
->where('date', '<', Carbon::now()->toDateString());
それは空のコレクションを返します。 $student->extras->where('find', 1)
戻り、このため、それは奇妙だ:私が間違ってやっている
2016-08-19
任意のアイデア:
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()
より道少ないのですか?
ような何かをする必要があると思いますあなたの先生ありがとうございました!ここで( 'find'、1) - > where( 'date'、 '<'、Carbon :: now()) - > get(); $ student-> extras();完全に動作します(get()を使用) –
' - > get()'を見つけて追加しました:) – Wader