私の Place モデルにこの関係がある場合:
public function openhours()
{
return $this->hasOne('Hours')->select(DB::raw("IF(CURTIME() BETWEEN open_time AND close_time ,'Open','Closed')"));
}
そして私のルートでは:
$place = Place::with('openhours')->where('id', '=', 5)->get();
私のテーブル:
Table Name : hours
Fields :
id int(11)
place_id int(11)
open_time time
close_time time
テーブル レコード:
id: 1
place_id: 5
open_time: 10:00:00
close_time: 17:00:00
それはただ返します:
openhours:null
このクエリを phpmyadmin で手動で実行すると、正常に動作します。
私は何を間違っていますか?
前もって感謝します。