I have at Maxoffer model:
protected $dates = [
'start'
];
public function setStartAttribute($date){
$this->attributes['start']= Carbon::createFromFormat('m/d/Y h:i a', $date);
}
public function getStartAttribute($date){
return (new Carbon($date))->toRfc2822String();
}
In my database start
is stored in format: 2016-02-02 00:00:00
Now when I try to run WHERE
query:
$maxoffer = Maxoffer::where('article_id', $request->input('article_id'))
->where('start', $request->input('start'))
->first();
dd($maxoffer);
Input(start)
is in format: 2016-02-02 12:00 am also i try to make it in this format: 2016-02-02 00:00:00 but again dont work so dd give me result null
I got a problem becouse I dont know how to compare start and input(start). How to make them at same format...
Also I cant change:
public function getStartAttribute($date){
return (new Carbon($date))->toRfc2822String();
}
becouse I need it at this format for other thing.
So how to make this possible?
Try below where the string is converted into Carbon time and Eloquent then can compare the times in DB
->where('start', Carbon::parse($request->input('start')))