Laravel 8 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 8 tutorial in this video we are going to learn about import data from excellent csv so let's see how can we import data from excel and csp here i am just going to use laravel excel package so first of all let's install this package so switch to the command prompt and here just type the command composer space required space mat website slash excel okay now press enter all right now package has been installed so switch to the project and let's make some configuration so just go inside the config directory then app.php and inside the providers array just add here match website excel okay and slash excel service provider all right column column class and inside the layers area just add here excel and mat website excel class facade class excel column column class okay now save this file now let's publish the configuration so switch to the command prompt and here just type the command php artisan vendor colon publish dash task provider is equal to mat website slash excel company now go to the php my admin so just here new uh open new tab and just open phpmyadmin and just open database laravel pro db2 and inside this database you can see here the employee table so just browse all right you can see here the table is empty okay now let's import uh record from csp and excel inside this table okay so let's switch to the project and inside the project you can see here inside the app directory models and here you can see the employee model okay now let's create the import class okay so inside the command prompt just right here hp artisan make uh call an import a space import class name let's say class name is employee import all right test set here the model so just right here model name which is this one employee okay so just right here imply now press enter all right import class has been created now switch to the project and just open import class so just to go inside that then imports and here just open employee import okay and inside this employee array here just add the column name okay so just right here uh column name which is name email phone salary department okay so just write here name arrow dollar row and just right here name okay now just copy this line and paste here all right now just write here email and here email phone also write your phone then salary and here saturday all right and here just add that department all right now save this file and here just add app class model uh models okay slash employee all right this is the correct path of employee model okay now save this file and here just add the with heading row so just type here use mat website excel slash concerns slash with instrument okay with link all right now just add here comma with all right now save this file now go to the employee model and just open models and employee model and here just add protected and create an array here and just add here the column name name email then on salary and department all right now save this file and now go to the employee controller so just open http then controllers and from here just open employee controller okay and inside this controller let's create a function so just right here public function and create a function for the creating a form import form just right here import form all right and inside this just return of view and let's say view name is import form all right now save this file and create routes for this so go to the web.php file inside the route directory just open web page and here create a route okay add uri import form all right and here the controller name which is employee controller okay column caller class and here the function name which is this one import form just copy and paste here now save this file and let's create this view so just copy and go to the view directory let's open resources then views and here just create a new file import form dot plate dot php all right so here just write boot a step five uh html5 boilerplate so just right here sign and press tab now just add here the title import okay input will be all right and here uh first of all let's add the step for cdn so go to the voterstrap.com now click on get started and from here just copy the css and base also and here all right now here just add text section and also save the padding so just right here style padding pop 20 pickup 60 pixel right and now just add the container then column program empty six say the offset offset empty green all right now add here that card card header and here just add the headings import all right and card body and inside this just add here the form so this type here and method post all right click type multiplatform data and inside this just add here at the let's see srf then uh it's here input field file okay so just right here input here so here first of all the class form group and create a label for title all right and just add here choose csv okay and input type is equal to file name also is a file and profile class class form control formed as control all right now add here submit button so just right here button type is equal to submit class all right now close this button and add here a text submit all right now let's check this form so go to the url import form so drop localhost is a thousand slash import form all right now press enter you can see here the import file all right now let's create one more function inside the employee controller so just right here public function import all right and here just pass request dollar request okay and first of all add here uh use f slash imports slash employee import okay now just write here excel column column import new employee import okay and here just a dollar request arrow all right and return simply return a message records are imported successfully all right now save this file now let's add the route for this function so just go to the web.php and here just add route get and uri with the import just add here the method host all right and add the controller name by controller one column class add the function name import right also add here the route name employee dot import right so just copy this route and go to the input form and here just add the action inside this form just right here action double curly bracket route just right here employee dot import now save this file and let's check so switch to the browser and here you can see the table is empty now just refresh the page and in my desktop you can see here the csv file and these are the records okay and in excel employee list dot excel file you can see here record okay so now let's import this records inside the table so just click on browse and browse the file from the desktop select employee list or csv file and now click on open and just click on submit you can see here records are imported successfully now go to the phpmyadmin and just refresh the table and you can see here the record okay now just remove all the record just delete yes now this is empty okay now let's import from the excel so just to go to the import transform and here just click on browse and this time just select employee list dot x sx file okay excel file and just click on open now click on submit okay import it and just refresh the table you can see here the records okay so in this way you can import data from csb and excel in laravel it so that's all about import data from csb and excel 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: 19,459
Rating: undefined out of 5
Keywords: How, to, Program, laravel (Software), laravel, laravel v8, laravel 8, laravel project, laravel setting up, laravel v8 setting up, laravel v8.0, v8.0, laravel 8.0, laravel 8 playlist, laravel 8 tutorial, laravel 8 lesson, laravel tutorial, laravel 8.0 tutorial for beginners, laravel for beginners, laravel tutorial for beginners, import data, import data from csv and excel in laravel 8, import csv data, import excel data, laravel 8 import data from csv and excel, csv, excel
Id: 7iHmrxfy9dY
Channel Id: undefined
Length: 18min 38sec (1118 seconds)
Published: Fri Sep 11 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.