AbdulBazith's avatar

suggestion for tables collision for main category and sub category of fee payment

Guys iam working with a school project. its a school management system.

whats my doubt is my application is dynamic, so the fee payment takes two steps,

fee structure and fee payment

first my doubt is in fee structure

the school posses Main category and sub category of fee, like below structure

Term1     payment duration (1-08-2019 to 15-08-2019)
    school Fee =  6000
    Bus Fee   =  3000
    Tution Fee= 2500

Term 2  payment duration (1-12-2019 to 15-12-2019)
    school Fee = 6000
    Lab Fee   =   3000

Term3   payment duration (1-03-2020 to 15-08-2020)
    School Fee= 6000
    extra fee = 2000

like this it goes on,

this structure may varies class wise (1 std 2nd std and so on...)

So for this i planned two tables to add the main category and the sub category.

table main category has columns like

  $table->bigIncrements('id');
            $table->bigInteger('acc_year_id')->unsigned();
            $table->foreign('acc_year_id')->references('id')->on('academic_years')->onDelete('cascade');
            $table->string('fee_main_cat');
            $table->date('due_start_date')->nullable();
            $table->date('due_end_date')->nullable();
            $table->bigInteger('total_amt')->nullable();
            $table->longText('note')->nullable();
            $table->string('status')->nullable();
            $table->timestamps();

the view of the above table is : https://imgur.com/Gwo9vYQ

and sub category table has columns below

 $table->bigIncrements('id');
            $table->bigInteger('acc_year_id')->unsigned();
            $table->foreign('acc_year_id')->references('id')->on('academic_years')->onDelete('cascade');
            $table->bigInteger('class_id')->unsigned();
            $table->foreign('class_id')->references('id')->on('class_details')->onDelete('cascade');
            $table->bigInteger('fee_main_cat_id')->unsigned();
            $table->foreign('fee_main_cat_id')->references('id')->on('fee_main_cats')->onDelete('cascade');
            $table->string('fee_sub_cat');
            $table->bigInteger('amt')->nullable();
            $table->longText('note')->nullable();
            $table->string('status')->nullable();

the view of the above table is : https://imgur.com/bNX2JOR

whether the above columns are right.

so for this i have created a form like this : https://imgur.com/z6AY2xX

in this form to add sub category i used table because for one main category there may be 2 or 3 sub categories.

in some occurrence there may not be any sub categories.

here whats the problem iam facing is, i planned everything, the fee main category which is typed by the user in the form will be added to the main category table, and the id of that is picked, and it is added to the sub categories table with its details. here the problem is i should not enter the main category two times, so used datalist in html, which act as textbox and aswell as dropdown. if data there it shows else user can enter.

but i failed. then only i got confusion.

is one form is enough for both. else need two forms.

kindly suggest your ideas please

0 likes
7 replies
michapietsch's avatar

@abdulbazith So you need the user to be able to either choose an existing main category or enter a new one?

Yu could check in the controller if a main category id is provided in the request or if you have a new main category name and create this first.

Is that what you want?

1 like
AbdulBazith's avatar

@michapietsch thank you soo much for your response.

ya thats what i expect.

but the problem is whether to keep a text box in the form or drop down. if already it is there its id should be used. else the new record should be created.

textbox?? or dropdown?? or datalist?? which to use??? in the form??

1 like
michapietsch's avatar

@abdulbazith I think I'd go with both:

Label: Choose a category Dropdown for category

Label: Or create a new one Text input

Then use that on the server.

1 like
michapietsch's avatar
Level 10

@abdulbazith You have two options:

  1. Show both the text box and dropdown and decide on the server what to do. But there is a problem: How do you validate if the user entered at least one of them as a required value? Or what if the user fills both?

So, there's a second option, closer to what you already mentioned ("check box or radio button"):

  1. Give the user a choice and/or use some JavaScript to make sure you get the required data. You could show the dropdown and the text box, but disable one if the user enters or selects a value in the other one. Or you use a checkbox or radio button to toggle visibility. But even an invisible field could be submitted to the server.

Do you have experience with JavaScript? I recommend you watch the series on Vue and then decide if you want to build it like that.

michapietsch's avatar

@abdulbazith I'm happy to help! Would please be so kind to mark the helpful answer to mark this topic as solved?

I will take a look at the other topic.

1 like

Please or to participate in this conversation.