I have a model Article
(id, title, content, created_at).
I can do:
$articles = Article::orderBy('created_at','DESC')->skip($start)->take($length)
->get(['id', 'title', 'content', 'created_at']);
But I want to get 2 random additional articles for each article . How can I do it?
For example:
{
{
id: 1,
title: 'title1'
content: 'qwqwqwqwqwqwqwq',
created_at: '2022-11-25 14:04:35',
related: {
id: 77,
title: 'title77'
content: 'fhhhfh',
created_at: '2022-11-26 17:04:57',
},
{
id: 15,
title: 'title15'
content: 'kkkkkkkk',
created_at: '2022-11-27 15:04:45',
},
},
...
}