Query to check if user_id exist in multiple tables
I am having 4 tables in my database,
users
profiledetails has FK user_id
physical has FK user_id
education has FK user_id
Scenario 1
Signup are stored in users table
After successfully signed up , They need to go through registration process.
Registration process is 3 different form for 3 different table as mention above.
Scenario 2
User has logged in, who is already signed up user
I would like to check weather he has filled up all the form or not, if not redirect to specific form,
You can simply check if the relation between the items exists. Note that this only works if you have setup the relations correctly
$user = Auth::user();
$user->load(['profiledetails', 'physical', 'education']);
if (! $user->education) {
// redirect to education form
}
if (! $user->physical) {
// redirect to physical form
}
// And so on.
If there is no relation set yet it will return null so you can check for that