Laravel 5.7: Importing Excel file into two tables via foreign keyCan table columns with a Foreign Key be NULL?Importing Excel spreadsheet into sql as a table errorHow to check if the first row or columns of Excel file is valid in Laravel Excel?Get results from pivot table based on the combination of two IDs in Laravel ProjectLaravel 5.7 Multiple foreign key referencing to same table primary keyLaravel 5.7 foreign key constraint is incorrectly formedHow to insert data via seeding Laravel 5.7 into two relation tables?Laravel 5.7 Excel maatwebsite 3.1 add foreign key on importsLaravel 5.7 Export File to ExcelLaravel 5.7 Import Excel File: Undefined offset
How to make a language evolve quickly?
Names of the Six Tastes
Is there an application which does HTTP PUT?
How are one-time password generators like Google Authenticator different from having two passwords?
Removing all characters except digits from clipboard
Is there some sort of formula to determine how many bricks I would need to build a completely new structure?
Company threw a surprise party for the CEO, 3 weeks later management says we have to pay for it, do I have to?
How is CoreiX like Corei5, i7 is related to Haswell, Ivy Bridge?
How can I avoid subordinates and coworkers leaving work until the last minute, then having no time for revisions?
What can cause an unfrozen indoor copper drain pipe to crack?
Improving Sati-Sampajañña (situative wisdom)
What is the criteria of choosing a given pin pattern in ICs?
How to rename pi as another value only for y axis without affecting pi used in x axis?
Has there been evidence of any other gods?
Was Mohammed the most popular first name for boys born in Berlin in 2018?
Is every story set in the future "science fiction"?
Why can't I prove summation identities without guessing?
I might have messed up in the 'Future Work' section of my thesis
Is it a Munchausen Number?
Why was wildfire not used during the Battle of Winterfell?
Different problems with tabularx
Why are low spin tetrahedral complexes so rare?
Examples where existence is harder than evaluation
Program for finding longest run of zeros from a list of 100 random integers which are either 0 or 1
Laravel 5.7: Importing Excel file into two tables via foreign key
Can table columns with a Foreign Key be NULL?Importing Excel spreadsheet into sql as a table errorHow to check if the first row or columns of Excel file is valid in Laravel Excel?Get results from pivot table based on the combination of two IDs in Laravel ProjectLaravel 5.7 Multiple foreign key referencing to same table primary keyLaravel 5.7 foreign key constraint is incorrectly formedHow to insert data via seeding Laravel 5.7 into two relation tables?Laravel 5.7 Excel maatwebsite 3.1 add foreign key on importsLaravel 5.7 Export File to ExcelLaravel 5.7 Import Excel File: Undefined offset
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;
I've tried importing an excel file into a single table and it worked perfectly, but the problem is, the Census module where it lets the user to add new resident along with the details needed, now every time a user adds a new resident it also reflects to the user table through the use of the user_no foreign key in the Residents Table. I want to achieve that while importing an excel file. is that possible? (pardon me I'm still a newbie with laravel)
here's my code for adding a resident:
public function store(Request $request)
$residents = new Resident;
$residents->resident_fname = $request->input('resident_fname');
$residents->resident_lname = $request->input('resident_lname');
$residents->resident_mi = $request->input('resident_mi');
$residents->resident_email = $request->input('resident_email');
$residents->resident_age = $request->input('resident_age');
$residents->resident_dob = $request->input('resident_dob');
$residents->role = 'resident';
$residents->resident_address = $request->input('resident_address');
$residents->resident_contact = $request->input('resident_contact');
$residents->resident_gender = $request->input('resident_gender');
$residents->ResidentVoter_status = $request->input('ResidentVoter_status');
$residents->resident_status = $request->input('resident_status');
$residents->resident_religion = $request->input('resident_religion');
$residents->resident_purok = $request->input('resident_purok');
$residents->save();
$res_id = Resident::orderBy('created_at', 'desc')->first();
$user = new User;
$user->name = $request->input('resident_fname');
$user->email = $request->input('resident_email');
$user->password = Hash::make('123456');
$user->role = 'resident';
$user->res_id = $res_id->id;
$user->save();
return redirect('/residents')->with('success', 'Successfully Added!');
Here's my code for the ResidentImport model:
public function model(array $row)
return new Resident([
'resident_fname' => $row[0],
'resident_lname' => $row[1],
'resident_mi' => $row[2],
'resident_dob' => PhpOfficePhpSpreadsheetSharedDate::excelToDateTimeObject($row['3']),
'role' => $row[4],
'resident_age' => $row[5],
'resident_address' => $row[6],
'resident_contact' => $row[7],
'resident_email' => $row[8],
'resident_purok' => $row[9],
'resident_status' => $row[10],
'resident_gender' => $row[11],
'resident_religion' => $row[12],
'ResidentVoter_status' => $row[13],
]);
while this is my ResidentImport Controller:
public function import(Request $request)
$import = Excel::import(new ResidentImport, request()->file('import_file'));
return redirect('/importing')->with('success', 'Imported Successfully!');
I absolutely dont have an idea with what to do with this. can anyone help me please?
database laravel import laravel-5.7
add a comment |
I've tried importing an excel file into a single table and it worked perfectly, but the problem is, the Census module where it lets the user to add new resident along with the details needed, now every time a user adds a new resident it also reflects to the user table through the use of the user_no foreign key in the Residents Table. I want to achieve that while importing an excel file. is that possible? (pardon me I'm still a newbie with laravel)
here's my code for adding a resident:
public function store(Request $request)
$residents = new Resident;
$residents->resident_fname = $request->input('resident_fname');
$residents->resident_lname = $request->input('resident_lname');
$residents->resident_mi = $request->input('resident_mi');
$residents->resident_email = $request->input('resident_email');
$residents->resident_age = $request->input('resident_age');
$residents->resident_dob = $request->input('resident_dob');
$residents->role = 'resident';
$residents->resident_address = $request->input('resident_address');
$residents->resident_contact = $request->input('resident_contact');
$residents->resident_gender = $request->input('resident_gender');
$residents->ResidentVoter_status = $request->input('ResidentVoter_status');
$residents->resident_status = $request->input('resident_status');
$residents->resident_religion = $request->input('resident_religion');
$residents->resident_purok = $request->input('resident_purok');
$residents->save();
$res_id = Resident::orderBy('created_at', 'desc')->first();
$user = new User;
$user->name = $request->input('resident_fname');
$user->email = $request->input('resident_email');
$user->password = Hash::make('123456');
$user->role = 'resident';
$user->res_id = $res_id->id;
$user->save();
return redirect('/residents')->with('success', 'Successfully Added!');
Here's my code for the ResidentImport model:
public function model(array $row)
return new Resident([
'resident_fname' => $row[0],
'resident_lname' => $row[1],
'resident_mi' => $row[2],
'resident_dob' => PhpOfficePhpSpreadsheetSharedDate::excelToDateTimeObject($row['3']),
'role' => $row[4],
'resident_age' => $row[5],
'resident_address' => $row[6],
'resident_contact' => $row[7],
'resident_email' => $row[8],
'resident_purok' => $row[9],
'resident_status' => $row[10],
'resident_gender' => $row[11],
'resident_religion' => $row[12],
'ResidentVoter_status' => $row[13],
]);
while this is my ResidentImport Controller:
public function import(Request $request)
$import = Excel::import(new ResidentImport, request()->file('import_file'));
return redirect('/importing')->with('success', 'Imported Successfully!');
I absolutely dont have an idea with what to do with this. can anyone help me please?
database laravel import laravel-5.7
add a comment |
I've tried importing an excel file into a single table and it worked perfectly, but the problem is, the Census module where it lets the user to add new resident along with the details needed, now every time a user adds a new resident it also reflects to the user table through the use of the user_no foreign key in the Residents Table. I want to achieve that while importing an excel file. is that possible? (pardon me I'm still a newbie with laravel)
here's my code for adding a resident:
public function store(Request $request)
$residents = new Resident;
$residents->resident_fname = $request->input('resident_fname');
$residents->resident_lname = $request->input('resident_lname');
$residents->resident_mi = $request->input('resident_mi');
$residents->resident_email = $request->input('resident_email');
$residents->resident_age = $request->input('resident_age');
$residents->resident_dob = $request->input('resident_dob');
$residents->role = 'resident';
$residents->resident_address = $request->input('resident_address');
$residents->resident_contact = $request->input('resident_contact');
$residents->resident_gender = $request->input('resident_gender');
$residents->ResidentVoter_status = $request->input('ResidentVoter_status');
$residents->resident_status = $request->input('resident_status');
$residents->resident_religion = $request->input('resident_religion');
$residents->resident_purok = $request->input('resident_purok');
$residents->save();
$res_id = Resident::orderBy('created_at', 'desc')->first();
$user = new User;
$user->name = $request->input('resident_fname');
$user->email = $request->input('resident_email');
$user->password = Hash::make('123456');
$user->role = 'resident';
$user->res_id = $res_id->id;
$user->save();
return redirect('/residents')->with('success', 'Successfully Added!');
Here's my code for the ResidentImport model:
public function model(array $row)
return new Resident([
'resident_fname' => $row[0],
'resident_lname' => $row[1],
'resident_mi' => $row[2],
'resident_dob' => PhpOfficePhpSpreadsheetSharedDate::excelToDateTimeObject($row['3']),
'role' => $row[4],
'resident_age' => $row[5],
'resident_address' => $row[6],
'resident_contact' => $row[7],
'resident_email' => $row[8],
'resident_purok' => $row[9],
'resident_status' => $row[10],
'resident_gender' => $row[11],
'resident_religion' => $row[12],
'ResidentVoter_status' => $row[13],
]);
while this is my ResidentImport Controller:
public function import(Request $request)
$import = Excel::import(new ResidentImport, request()->file('import_file'));
return redirect('/importing')->with('success', 'Imported Successfully!');
I absolutely dont have an idea with what to do with this. can anyone help me please?
database laravel import laravel-5.7
I've tried importing an excel file into a single table and it worked perfectly, but the problem is, the Census module where it lets the user to add new resident along with the details needed, now every time a user adds a new resident it also reflects to the user table through the use of the user_no foreign key in the Residents Table. I want to achieve that while importing an excel file. is that possible? (pardon me I'm still a newbie with laravel)
here's my code for adding a resident:
public function store(Request $request)
$residents = new Resident;
$residents->resident_fname = $request->input('resident_fname');
$residents->resident_lname = $request->input('resident_lname');
$residents->resident_mi = $request->input('resident_mi');
$residents->resident_email = $request->input('resident_email');
$residents->resident_age = $request->input('resident_age');
$residents->resident_dob = $request->input('resident_dob');
$residents->role = 'resident';
$residents->resident_address = $request->input('resident_address');
$residents->resident_contact = $request->input('resident_contact');
$residents->resident_gender = $request->input('resident_gender');
$residents->ResidentVoter_status = $request->input('ResidentVoter_status');
$residents->resident_status = $request->input('resident_status');
$residents->resident_religion = $request->input('resident_religion');
$residents->resident_purok = $request->input('resident_purok');
$residents->save();
$res_id = Resident::orderBy('created_at', 'desc')->first();
$user = new User;
$user->name = $request->input('resident_fname');
$user->email = $request->input('resident_email');
$user->password = Hash::make('123456');
$user->role = 'resident';
$user->res_id = $res_id->id;
$user->save();
return redirect('/residents')->with('success', 'Successfully Added!');
Here's my code for the ResidentImport model:
public function model(array $row)
return new Resident([
'resident_fname' => $row[0],
'resident_lname' => $row[1],
'resident_mi' => $row[2],
'resident_dob' => PhpOfficePhpSpreadsheetSharedDate::excelToDateTimeObject($row['3']),
'role' => $row[4],
'resident_age' => $row[5],
'resident_address' => $row[6],
'resident_contact' => $row[7],
'resident_email' => $row[8],
'resident_purok' => $row[9],
'resident_status' => $row[10],
'resident_gender' => $row[11],
'resident_religion' => $row[12],
'ResidentVoter_status' => $row[13],
]);
while this is my ResidentImport Controller:
public function import(Request $request)
$import = Excel::import(new ResidentImport, request()->file('import_file'));
return redirect('/importing')->with('success', 'Imported Successfully!');
I absolutely dont have an idea with what to do with this. can anyone help me please?
database laravel import laravel-5.7
database laravel import laravel-5.7
edited Mar 23 at 10:48
asdfg_rocks
767
767
asked Mar 23 at 9:34
Arato Arato
52
52
add a comment |
add a comment |
0
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55312398%2flaravel-5-7-importing-excel-file-into-two-tables-via-foreign-key%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55312398%2flaravel-5-7-importing-excel-file-into-two-tables-via-foreign-key%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown