I'm not sure to understand what you're trying to do.
Will the user be able to choose what chart type to display and what datas to display in the chart ? All this dynamically ?
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
What is my best course of action, here is the situation. My system is a survey building platform, now I'm trying to add a charts report part that adds specific charts in order to generate a report page. that's where I need help, I have my database changes but I'm unsure how to setup my backend.
Here is my database
Schema::create('chart_types', function (Blueprint $table) {
$table->uuid('id')->primary();
$table->string('name')->unique();
$table->string('display_name');
$table->timestamps();
$table->softDeletes();
});
Schema::create('survey_chart_queries', function (Blueprint $table) {
$table->uuid('id')->primary();
$table->string('name')->unique();
$table->string('display_name');
$table->timestamps();
$table->softDeletes();
});
Schema::create('survey_charts', function (Blueprint $table) {
$table->uuid('id')->primary();
$table->string('title')->unique();
$table->string('options');
$table->string('number');
$table->foreignUuid('survey_id')->constrained()->onDelete('cascade');
$table->foreignUuid('chart_type_id')->constrained()->onDelete('cascade');
$table->foreignUuid('survey_chart_query_id')->constrained();
$table->timestamps();
$table->softDeletes();
});
Here are examples of Chart Types
[
'id' => 'df58afbd-5e37-4b85-9b0f-b214b4a588aa',
'name' => 'bar',
'display_name' => 'Bar'
],
[
'id' => 'c6b661a8-65ee-4d16-8d0f-ba3edc82ae04',
'name' => 'line',
'display_name' => 'Line'
],
[
'id' => '9290617f-d742-4be0-bd99-acb05ef58171',
'name' => 'polar',
'display_name' => 'Polar'
],
[
'id' => 'cb03b280-0cfb-4c88-a428-4fb99cdb4b81',
'name' => 'doughnut',
'display_name' => 'Doughnut'
],
and Survey Chart Queries. The idea here is to set which what is being shown in the chart, this part is the most 'hardcoded' because depending on the report the options will change.
[
'id' => '132b8530-767a-476a-995a-a65b9d0e8ac5',
'name' => 'avg-team-grade',
'display_name' => 'Average Team Grade'
],
[
'id' => 'f0836e5d-8b19-4a06-a50c-3e0d16de76c4',
'name' => 'qty-merchandisers',
'display_name' => 'Quantity Merchandisers'
],
[
'id' => '3686c760-d5e1-4b9c-863b-ea40808038f4',
'name' => 'avg-sale-point-grade',
'display_name' => 'Average Sale Point Grade'
],
[
'id' => 'c11b0285-c141-437a-8739-1c757d1525d8',
'name' => 'grade-by-other-restriction-groups',
'display_name' => 'Grade by Restriction Groups'
]
I'm sorry if I didn't explain it right but let me add an example: for a report for a Supervisor it would be all the users that have userType = Supervisor, when you go to add the charts you can only add ones from an approved list and they also depend on the chart type, so the Line Chart will have different options from a Bar Chart. (I think that's more a front-end problem though to choose the correct ones)
My questions are first: how does this look so far? I can make changes to the database if needed and second: how would you continue from here, I'm not expecting the actual searches or anything but how would you create the queries, where should that code go?
Anything would be helpful, thanks.
Please or to participate in this conversation.