laravel - 创建报告系统
问题描述
我正在尝试在 Laravel 中创建一个报告系统。
这是我的架构:
Schema::create('reports', function (Blueprint $table) {
$table->bigIncrements('id');
$table->unsignedBigInteger('user_id')->nullable();
$table->unsignedBigInteger('reportable_id')->nullable();
$table->string('reportable_type')->nullable();
$table->string('body');
$table->timestamps();
$table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
});
我想要实现的是当用户报告时,传递到路由中的模型(即线程、回复、用户、帖子)被记录在数据库中。
Route::post('/report/{model}', 'ReportController@store');
我做了一些研究,无法将对象传递到请求中。
我如何着手创建这个系统?还有其他我应该考虑的选择吗?
谢谢!
解决方案
您可以在发布请求中发送模型名称和 ID。使用输入字段
推荐阅读
- python - 我不断收到这个 AttributeError: '_tkinter.tkapp' 对象没有属性 'TK'
- python - PyQGIS在导入csv时更改底图crs
- google-cloud-platform - 如何将项目链接到链接到不同帐户的 GCP 积分?
- java - 如何在spring rest控制器中获取发件人的uri?
- c# - 您好,我想知道这种条件语句是什么意思?if (i == 0) 最低 = 最高 = 输入;
- python - 无法将正确的格式应用于熊猫日期框
- c - 管道和控制台的区别
- android - 什么是 provideLayout()?.let { setContentView(it) }?
- powershell - 为什么Powershell运行的应用程序没有出现在远程桌面上,而是出现在任务管理器中?
- scala - 如何将字符串序列添加为 dataFrame 上的列并进行转换