Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/247.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/mongodb/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php Laravel-仅限返回的hasManyThrough\u id_Php_Mongodb_Laravel_Eloquent_Laravel 5.5 - Fatal编程技术网

Php Laravel-仅限返回的hasManyThrough\u id

Php Laravel-仅限返回的hasManyThrough\u id,php,mongodb,laravel,eloquent,laravel-5.5,Php,Mongodb,Laravel,Eloquent,Laravel 5.5,我使用jenssegers的Laravel MongoDB包和雄辩的Laravel模型 文章: _id(ObjectID) 饲料标识 头衔 提要: 身份证 用户id 名字 用户: 身份证 名字 hasManyThrough在User::class模型中,一个用户可以获取所有文章 public function articles() { return $this->hasManyThrough( 'App\Article', 'App\Fe

我使用jenssegers的Laravel MongoDB包和雄辩的Laravel模型

文章:

  • _id(ObjectID)
  • 饲料标识
  • 头衔
提要:

  • 身份证
  • 用户id
  • 名字
用户:

  • 身份证
  • 名字
hasManyThrough在User::class模型中,一个用户可以获取所有文章

public function articles()
{
    return $this->hasManyThrough(
        'App\Article',
        'App\Feed',
        'user_id', // Foreign key on feeds table...
        'feed_id', // Foreign key on articles table...
        '_id', // Local key on users table...
        'id' // Local key on feeds table...
    );
}
我通过此查询仅获得_id(ObjectID):

$user = \App\Models\User::find(1);
dd($user->articles);
你能帮我搜索这个问题吗?

你可以试试这个

$user->articles()->find(1);
如果您想要第一条记录,并且如果您想要所有记录,您可以使用
get()

另外,如果要放置约束,请使用
where()
而不是
find()

你可以试试这个

$user->articles()->find(1);
如果您想要第一条记录,并且如果您想要所有记录,您可以使用
get()

另外,如果要放置约束,请使用
where()
而不是
find()


你能在这里发布你从这个查询中得到的sql吗?你能在这里发布你从这个查询中得到的sql吗?