Hey guys,
Been trying to come with solution to translate this query as eloquent as possible, but keep PDOExceptioning; I'm using postgresql and using a migration class that will update jobs table.
i need to go over all records and update the end date if it is not in one year minus one day from start date.
query:
UPDATE jobs SET (start, end) = (start, start + interval '1 year' - interval '1 day')
WHERE start + interval '1 year' - interval '1 day' != end;
wishful thinking:
DB::table('jobs')
->where( ?? , '<>', ??)
->update([
'start' => DB::raw('start'),
'end' => Carbon::parse(DB::raw('start'))->addYear()->subDay()
]);
For now, unfortunately, i have no working solution, so any help/pointer to get me going would be more than appreciated.
Thank you in advance.
Can't you use something like
->whereRaw("start + interval '1 year' - interval '1 day' != end")
Hope that helps
Joel
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community