【问题标题】:Get only 2 rows from join table in laravel从 laravel 的连接表中只获取 2 行
【发布时间】:2020-03-28 20:05:31
【问题描述】:

我有两张桌子。主题和链接。 我只想要两个特定主题的链接。

【问题讨论】:

    标签: laravel eloquent


    【解决方案1】:

    您可以使用take 来获取所需的记录数量,如下所示:

    $topics = \App\Link::where('topic_id',$parricularTopic)->take(2)->get(); 
    

    【讨论】:

      猜你喜欢
      • 2023-04-04
      • 1970-01-01
      • 2018-12-21
      • 2011-08-24
      • 2021-10-03
      • 1970-01-01
      • 2017-04-02
      • 2021-07-18
      • 2021-10-16
      相关资源
      最近更新 更多