我正在尝试在Laravel中创建一个报告系统。
下面是我的schema:
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');
我做了一些研究,不可能将Object传递到请求中。
我该如何创建这个系统?我还需要考虑其他的选择吗?
谢谢!
您可以在post请求中发送模型名称和id。使用输入字段