Aug 19, 2019
0
Level 4
retrieve data related to related table on model query
hello, i have got tables articles, files and uploads
my current query
ArticleNew::where('article_id', 2931)
->with([
'files' => function($query){
$query->select('url', 'filename', 'mimetype', 'db_files_new.file_id')
->orderBy('file_id');
},
'uploads' => function($query){
$query->where('thumbnail_id', '!=', 0)
->select('db_uploads_new.file_id', 'thumbnail_id');
},
'category',
'relations',
])->select('article_id', 'lang_id', 'url', 'author_id', 'created_on', 'title', 'description', 'content')
->get();
it returns article itself and related files (images/videos) but if it is video then it got thumbnail paired via uploads table but this returns only thumbnail_id from uploads table and i also need to get data from files table for that thumbnail_id
Please or to participate in this conversation.