Kei*_*dge 5 php mysql laravel eloquent
我想知道是否可以检索与Eloquent关系的第一个元素.
这不起作用:
$posts = Post::with(['medias' => function($q) {
$q->where('type', 'landscape')
// not working
->limit(1);
// not working
->take(1);
// not working
->first();
}])->get();
Run Code Online (Sandbox Code Playgroud)
这是一对多的关系.
先感谢您 !