I have 2 tables: Quotes, answers.
In datatable, I show quotes, and for each row I show the number of responses in columns. I want to show the date of the last reply now, but I'm blocked :(
Here is my code:
$quotes = Quote::select('Quotes.*', DB::raw('COUNT(Responses.id) as total_responses') )
->leftjoin('Responses', function($join)
{
$join->on('Responses.quote_id', '=', 'Quotes.id')
->where('Responses.state', '!=', '0');
})
->groupby('Quotes.id');
Is it possible to add another left join with the same table, with a user query, to select only the last row?
thanks for the help
source
share