I just don't know what's wrong with my code and why it produces this error
SQLSTATE[23000]: Integrity constraint violation: 1052 Column 'created_at' in order clause is ambiguous (SQL: select * from
processes
inner joinbags
onprocesses
.bag_id
=bags
.id
wherebags
.type
= Recyclable and date(processes
.created_at
) = 2018-09-18 00:00:00 order bycreated_at
desc limit 1) and here's my code
$bag = Bagcollect::join('bags', 'bagcollects.bag_id', '=', 'bags.id')
->select('bags.type')
->where('bagcollects.bag_id', $request->input('bag_id'))
->first();
//this query produce error
$processexist = Process::join('bags', 'processes.bag_id', '=', 'bags.id')
->where('bags.type', $bag->type)
->whereDate('processes.created_at', Carbon::today())
->latest()
->first();
SELECT
,WHERE
,ON
(when joining),HAVING
,GROUP BY
clauses to add to @MadhurBhaiya 's comment – Raymond Nijland