gpt4 book ai didi

php - Laravel - 从数据库查询并保存到另一个

转载 作者:行者123 更新时间:2023-11-29 07:37:32 24 4
gpt4 key购买 nike

欢迎光临!我试图为我的问题找到解决方案,但对于新的 laravel 用户来说很难。我尝试做一些简单的预订系统。我有 2 个表:时间表和出价。我想要做的是显示时间表并通过“预订”按钮将其保存到出价表。我知道如何查询调度表,但我不知道如何编写 Controller 将相同的数据保存到另一个表。

问候并感谢您的帮助。

最佳答案

您可以在同一个 Controller 类中通过在其中添加一个新函数来实现。这是示例代码。

class YourController extends Controller
{

public function bookSchedule()
{
//here we are getting the data from the table
$s = Schedule::where('id','=',98)
->select('colomn_1','colomn_2')
->get()
->toArray();
// here we are storing it back to the bids table
Bids::insert($s);
}

希望回答对您有所帮助。

关于php - Laravel - 从数据库查询并保存到另一个,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48024186/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com