0

I have users table where role is a field in it which can be student, patent, teacher and admin.

I have to insert data in student form in one page, it can be done with users whose role is set to student. Now in another page there is a form for filling out additional data such as father and mother details.

I used two objects so that I can store this father and mother information.

Now when I click on next button these id's (student_id, father_id, mother_id) should be stored in student_parents table whose fields are student_id, parent_id, relation.

In nutshell there is a student form when I fill this and click on next button I have to enter parent form after filling this form both father_id, mother_id, student_id which comes from Users should be stored in student_patents table.I am new to this.By the way I am using Graphql and Vue.js.

Michael Mano
  • 3,339
  • 2
  • 14
  • 35
the_unknown
  • 51
  • 1
  • 1
  • Can you show us your existing code? Are you asking this from a form perspective or the backend relation? e.g. how is the parents relation set up? many to many pivot? if so `$student->parents->attach($parent_id);` im guessing laravel since the way you have the tables set up. – Michael Mano Dec 15 '21 at 03:36
  • Please provide enough code so others can better understand or reproduce the problem. – Community Dec 21 '21 at 12:44

1 Answers1

0

If you could provide us your code sample you would get more accurate answers.

  • One way is to use APis to POST data to server and then GET them back in another page.

  • The other solution is to store your data in LocalStorage and then use the stored data in another place.

  • if you want to save data as objects here is the way :

localStorage stores key-value pairs. So to store a entire javascript object we need to serialize it first (with JSON.stringify, for example):

localStorage.setItem('user', JSON.stringify(user));

Then to retrieve it from the store and convert to an object again:

var user = JSON.parse(localStorage.getItem('user'));

If we need to delete all entries of the store we can simply do:

Amin Arshadinia
  • 188
  • 1
  • 6