Laravel 7 Tutorial - Import Data From Excel and CSV

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hi everyone welcome back to the laravel 7 tutorial in this video we are going to learn about import data from excellent csb so let's see how we can import data from excel file and csv file for importing data from excel and csv file here i am just going to use laravel excel package okay so first of all install this package so switch to the command prompt and here first of all stop the running application so just press ctrl c now clear the screen and here just type composer let's space required let's space website slash excel okay now press enter so all right now package has been installed now make the some configurations so switch to the project and just go inside the config folder just open app.php file [Music] and here inside the providers just add here a provider for the actual package so just right here mat wait mad website slash excel or slash excel service provider column column class okay now add the aliases here so just write here excel slash mat website [Music] mad website excel then facades okay after this configuration now save the file and now publish the configuration so switch to the command prompt and here just write php partition vendor column publish space test as provider is equal to double quote website class excel slash excel service provider service provider okay i am in capital letter mat website excel excel service provider all right now press enter okay publishing complete now just create import class okay so just write here command php artisan make column import and here the input class name let's say employee [Music] import okay and also add here the model i'm going to use here my model employee okay this build model is already created in previous video now just press enter all right now run the application so just write your php agent okay application is running on local lost 8000 port just refresh the page okay it's running now switch to the project and just close this file and now go inside the app folder and import and just open employee import.php file okay and here first of all just right here use my website slash concerns slash with heading pro okay now just copy this with heading row and add here with comma okay now add here the column name okay let's see the column name so switch to the browser and just go to the localhost php my admin okay local slash php my admin this is the url of phpmyadmin now just open studentdb and here in previous video i have created a employees table and here is the column name so just add this column name inside this inside here okay so just write here name email phone salary so just write your name dollar row okay now copy this and paste four time all right now add here the email or in phone so just write here email okay name name email email all right and here phone phone now next one is salary salary and here is last one department department okay also copy and paste here all right name email phone gallery and department all right now save the file now go to the employee model so inside that folder you can see here the employee model just open it and here just add the fillable okay so just write here protected dollar fillable and fillable is equal to column name okay this column you just write here name email phone and salary and department salary department all right now save the file now go to the employee controller so just open http have http then controllers and just open employee controller okay and here just add the function public function name let's say function name is [Music] okay i am going to create a form so just return here a view for the form so so just copy this name and go inside the resources folder then views and here just create a new blade file import dashboard form that's blade dot php all right now just open this file and here first of all add the boilerplate html5 boilerplate so just write your explanation sign then press tab now change the title here just going to write here the title import employee okay employees now here just add the step cdn so go to the browser and you next tab and next app just right here get voterstrap.com and click on getting started now just copy the css and just paste here okay now also add the this js cdn copy and paste here all right now here just add the form okay for that uh first of all add the container so just right here dot container tab dot row tab dot column md6 dot set to the offset offset uh md three okay now here just uh at the form type so okay action for typing this is the blank and type multipart from data okay now add here at the rate cs here csrf and form group then create a label label for file and here just try to deliver choose choose file okay now add here the input file uh type input type file so just write here input type is equal to file also name is equal to file all right and class which is form control [Music] all right now add the submit button so just write your input type is equal to submit class class is equal to dtn dtn okay and value is equal to submit all right now save the file now just create the route for this method so go to the routes folder routes then open web dot php and here just add the route route gate and uri let's you know you are as import input just copy and paste here all right now save the file and let's check so go to the this url import as form localhost colon 8000 slash less important okay you can see here the form okay uh give some padding here top padding so go inside the import form blade and here just add the style padding top let's say okay now save the file and refresh the page okay now go to the employee controller and here create one more function uh public function and function name let's say function name is import okay and add here the request dollar request okay and here just write just add the use app import employee import and use excel okay this line and now here just add excel colon column import new employee input comma dollar request and what is the name name is file okay so just write here five all right now simply return and redirect to the route get all employed out okay let's check in previous previous video we have already created this routes okay so here i'm just redirect to this route okay get all employees now save the file now create the route for this just right here route post and here import controller name which is employee controller and create function name import okay also give the name here name input all right now go to the import form blade.php file and here just add the action double back curly bracket just write here the route and route name which is okay now save the file all right now just go to the import form all right before importing uh from file csv file and excel file first of all remove all records from this table okay so just click on this database and from here just click on empty okay all records has been removed now just click on browse okay you can see here there is no any records okay i have already created a file csv file and excel file okay you can see here this is the csv file okay and also you can see here the excel file okay now open it you can see here all right now switch to the browser and here just refresh the page [Music] just click on browse now choose the excel file so just like this now click on open and submit you can see here the records has been inserted okay [Music] and also you can see here record has been inserted now go back and select the csv file employee.csv file and open now click on submit you can see here record has been inserted okay so in this way you can import data from excel and csv file so that's all about import data from excel and csv so thanks for watching this video and if you still have any kind of question you can ask me in the comment box don't forget to subscribe my channel thanks for watching
Info
Channel: Surfside Media
Views: 5,685
Rating: undefined out of 5
Keywords: How, to, Program, laravel (Software), laravel, laravel v7, laravel 7, laravel project, laravel setting up, laravel v7 setting up, laravel v7.0, v7.0, laravel 7.0, laravel 7 playlist, laravel 7 tutorial, laravel 7 lesson, intro to laravel 7, laravel tutorial, laravel 7.0 tutorial for beginners, laravel for beginners, laravel tutorial for beginners, import data from excel and csv in laravel, import csv data in laravel 7, import excel data in laravel 7, csv in laravel 7
Id: 2_ieEV9_GC4
Channel Id: undefined
Length: 21min 29sec (1289 seconds)
Published: Wed Aug 05 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.