首页 > 解决方案 > 创建报告系统

问题描述

我正在尝试在 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');

我做了一些研究,无法将对象传递到请求中。

我如何着手创建这个系统?还有其他我应该考虑的选择吗?

谢谢!

标签: laravel

解决方案


您可以在发布请求中发送模型名称和 ID。使用输入字段


推荐阅读