use laravel relationship (Polymorphic) it will help you url :https://laravel.com/docs/7.x/eloquent-relationships#introduction
how to link all 5 tables with user table. using polymorphic table or any other idea
i have finished a school project.but due to this vacation iam restructuring the project.
i need to get the students data in the school application.
students data i differentiated into
Academic info
personal info
parents info
siblings info
address info
previous education info
so i need to ling all the tables with student_id
in my old project what i did is
i had a form to get all the above details in a single form and then what i did is
// first few data will be stored in user table
$user = User::create([
'year_id' => $request->acc_year_id,
'user_name' => $username,
'user_type' => 'student',
'admission_number' => $request->admin_no,
'user_phno' => $request->stud_sms_no,
'password' => $request->admin_no,
'status' => $request->status,
]);
so for each student an account will be created this is because student also has logins thats why. next
$last_id = $user->id;
$admininfo = new StudentAdmissionInfo;
$admininfo->student_id = $last_id;
$admininfo->admin_no = trim($request->admin_no);
$admininfo->admin_date = trim($request->admin_date);
$admininfo->admin_class_id = trim($request->admin_class_id);
$admininfo->admin_section_id = trim($request->admin_section_id);
$admininfo->stud_roll_no = trim($request->stud_roll_no);
$admininfo->stud_type = trim($request->stud_type);
$admininfo->status = trim($request->status);
$admininfo->save();
.
.
.
the remaining data will be stored in corresponding table with student_id which is created above.
so by this user table will be parent table and all other will be the child table.
everything went correct.
now iam restructuring the work. let the format be correct else can i use polymorphic table??
if i use polymorphic table how i can link all the tables to a single student. and how i can add the student in user table??
kindly some one suggest.
i have another doubt
iam storing the student address in this format
StudentAddressInfo
id student_id addr_type address pincode state country
1 1 temporary 1-1 555 TN india
2 1 permanent 2-2 666 TN india
3 2 both 5-5 777 TN india
IF a student have two type of address like temporary and permanent this format ok.
most of the student have same address for that how i can store this in studentAddressInfo??
their permanent and present address will be same. how i can store. what i did is
just changes the addr_type and both but while editing i face lots of issue
Kindly some one help please
Please or to participate in this conversation.