如何在 Laravel 7 中将 HTTP 请求数据和用户数据保存到数据库中?
正如标题所说,我想知道如何将 HTTP 请求数据和用户数据保存到我的数据库中。我正在使用 Postgres。
我谷歌了一下,找到了一个答案,例如 如何保存Laravel Rest Api 登录到 db 但它已经有 3 年左右的历史了,所以我不确定 Laravel 发生了多少变化。我仍然是 Laravel 的菜鸟,所以我希望能在这方面得到一些帮助。
我当前的想法是尝试获取我的请求数据并将其直接保存到我的数据库中,但我不确定如何实现这一点。我也研究了 Monolog,但找不到任何有帮助的东西。
这是我的迁移文件中的一个片段。
$table->id();
$table->string('last_name')->nullable();
$table->string('first_name')->nullable();
$table->string('email')->nullable();
$table->string('method');
$table->string('url');
$table->string('body')->nullable();
$table->string('received_at');
$table->string('ip');
$table->string('agent')->nullable();
$table->integer('user_id')->nullable();
$table->timestamps();
$table->softDeletes();
As the title says I want to know how to save HTTP request data and user data into my database. I am using Postgres.
I google around a bit and found an answer such as How to Save Laravel rest Api logs into db but it is around 3 years old so I am not sure how much things have changed with Laravel. I am still pretty much a noob at Laravel, so I was hoping I could get some help on this.
My current idea is to try to get my request data and save it directly to my database, but I am unsure of how to implement this. I looked into Monolog as well but couldn't find anything that would be of help.
This is a snippet from my migration file.
$table->id();
$table->string('last_name')->nullable();
$table->string('first_name')->nullable();
$table->string('email')->nullable();
$table->string('method');
$table->string('url');
$table->string('body')->nullable();
$table->string('received_at');
$table->string('ip');
$table->string('agent')->nullable();
$table->integer('user_id')->nullable();
$table->timestamps();
$table->softDeletes();
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论