简体   繁体   English

如何在一张表中多次使用一个外键获取 Laravel 中的数据?

[英]How I fetch the data in Laravel using one foreign key in one table at multiple times?

Here is the attached image to show what I'm asking for?这是显示我要什么的附加图片?

在此处输入图像描述

In the CheckedIn model, I want to get the data that belong to the foreign key called checkInUserID .CheckedIn model 中,我想获取属于名为checkInUserID的外键的数据。

You have to create a relationship between the two tables in your Modal.您必须在 Modal 中的两个表之间创建关系。 This will let you directly access all the values that are in relation to that particular Modal.这将让您直接访问与该特定模态相关的所有值。

To know how it works check out Eloquent-Relationships要了解它是如何工作的,请查看Eloquent-Relationships

You can also check out this tutorialLaracast-Foreign-Keys (Highly recommended for understanding)你也可以看看这个教程Laracast-Foreign-Keys (强烈推荐理解)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用CakePHP 2再创建一个外键来获取数据 - Using CakePHP 2 to make one more foreign key hop to fetch data 如何使用php和mysqli一次查询获取多个表的数据? - How to fetch the data of multiple table with one query using php and mysqli? 如何将数据插入一个表并获取主键作为外键插入另一个表中? - How do I insert data into one table & get the primary key to insert in another table as a foreign key? 如何使用 CodeIgniter 3 中的外键从表中获取列数据 - How to fetch columns data from a table using the foreign key in CodeIgniter 3 如何在 Laravel 中使用一列作为多外键? - How can I use one column as multi foreign key in Laravel? 从外键“一对一关系”中检索数据。 拉拉韦尔 - Rretrieving data from foreign key, One to One Relationship. Laravel Codeigniter:如何使用外键ID从外表获取不同的列数据? - Codeigniter : How to fetch different column data from foreign table using foreign key id? 如何在laravel中使用外键参考单个表获取两个记录 - how to fetch two records with reference to single table using foreign key in laravel 如何从一个表中获取值并插入到第二个表中,同时如何将数据作为后端函数插入第二个表中。 使用laravel 5.2 - how to fetch value from one table and insert into second table while inserting data to the second table as backend function. using laravel 5.2 如何使用Laravel关系船在一个对象中获取数据 - How to fetch data in one object using laravel relation ship
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM