Laravel CRUD: Bootstrap Modal: Insert Data into Database (POP UP Modal)

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hey guys welcome back so guys in this video we are going to learn about how to insert the data using bootstrap model okay the laravel crud we are going to do so using bootstrap model a pop-up model we will be doing the insertion of data okay so let's get started so first thing you have to do is that set up your env file that whatever the data is okay and according to it so now we are going to do a model okay that is pop-up model and insert the data with that okay so with the help of resource control I'll be inserting the data so guys first thing we have to do is that create a table for it okay so as simple so let's create a table PHP artisan make migration I am going to create a employee table okay so that is create underscore employee table okay a table name all this should be plural okay so just give enter and yeah our table is created now so now let's go into the database migrations we'll find one data okay table so now we are going to enter some contents into it so like so I'll enter for contents so that is string string of name string of that it'd be first name and this last name the next is address and this mobile number okay so I'll give mobile and really make it as string this also okay so guys let's migrate this table PHP artisan migrate okay so our table is migrated into the database so it's now let's close this and we'll create one form okay so inside views there are many contents so do not consider it on them so let's create on model okay so employee model I'm going to create dot blade dot PHP okay so let's give enter and employee model is ready so now we will create I have three ml content okay so now inside this I am going to mention with the container so container with the heading so I'm going to do is that laravel crud mmm boot strap model okay so a simple that is nothing but your pop-up model okay so now let me sit and let me first view this page so to work with one form you have to create one happen okay so we have to create one controller and give some route and all to it so guys first we'll create one controller I mean model first PHP artisan make : model that is employee model I'm going to create just give enter an own model is created now with this let's see inside up employee okay we have model and now let's create one controller PHP artisan make controller that is make controller controller name that is employee controller with the resource I am going to create a resource controller okay so we will be working with that resource controller to do the crud okay so now let's minimize this and let's see inside app HTTP controller I employ controller is ready with our resource controller so resource controller means index create store show edit update and destroy so we will get all the things with that resource controller okay so guys now we will be displaying this form first thing so now we will go to routes web dot PHP let's create a route okay a simple route so if you are using resource controller to directly use a resource okay service a function that is mmm give a URL like I'm going to give employee okay and your m2 controller so we just now we created called employee controller so copy that okay whatever or you can directly type it so I'm going to use that employee controller so the resource will understand everything by itself so at index it will go first thing it will go to index so let's return at this return view what you're going to view is that the model okay so inside resource views I am going to view this EMP model okay so employee model page I am going to you EMP mo de ok so model saved and now guys let's solve the audition I mean let's leave this first clear hundred yeah so PHP artisan stuff let's see the output of it okay so we should get this output what is the page thing ok so now let's go to our refresh and okay so I have already sceptered some contents so this is a previous video okay where I was teaching about event calendar so I'll just the bootstrap model so now we will be viewing this page right so what we have given is that route is employed so let's go give us life and first type employee so laravel cred with the bootstrap model okay so now mm-hmm yeah so let's start with the model and insert the data okay as simple so guys first you have to do is that go to your browser go to your model okay get bootstrap come from there click on documentation okay I simple go to components inside that you'll find model okay so model is over here so I'm going to copy on model so let's see this example yeah this is fine so let's copy this okay so I'll copy this model and paste it over here okay so let me close this and yeah so this is my model okay so it is mentioned over here a model and like let me say this is start add model okay and and ad model done so this is the button to launch so to work with this first thing you have to do is that copy the link okay so let's so I'll copy the CSS link copied go to your tie I'm in head tag paste it over there okay and now um we have to take this JavaScript also okay so just copy that and paste it before the body close okay I am now done so guys now let's see the output of this go we reload the page and you'll get like this okay so let's launch it you will get the content okay so let's design the input form inside the body of it okay so go to bootstrap components forms okay so I'll take free forms in from this I'm going to copy some content of that okay so I'll just take this one first demo itself first one only so I'll paste it okay so this is my form right so what I'm going to do is that I will take this form outside the body okay and just paste it and after the button closed okay so as simple no confusion and now we will change it according to our way so so guys I have changed now I just pause the video and did with it so let's first name you have to do last name address and mobile according to your data table contents okay so input type text where I am giving F name LM address and mobile please do not mention any idea over here okay so we will just use the name thing okay don't mention any ID like this to it okay just leave it with the name so guys and please make sure that the button type is equal to you have to give submit okay so make sure that submit and let's give a form action so form action is equal to what action you are going to give okay and method is equal to post done and this is all form flows this is one sector and this is another sector okay so inside that it is closed so guys now let's view the output of it so let's go refresh so I some design will be done in next video where we'll I mean to display the data okay so let's click a model so you are getting all the data is unit now you will insert some data and save it according the database okay so but we don't have that till now okay so when you save that it should go and save to the database right so we will code now mmm yeah let's get started today still we have to give the action that is action of what you're employed controller okay so I'm going to give my controller name called employee controller at store okay so at store I will give it so this employee controller is nothing but my inside app HTTP controller employee controller okay so I'm going to give at that ad and it will go in to the store function okay so as simple so it's not first wheel to complete this so after this form you have to give a security token for the laravel that is CES RF okay CS RF underscore fi eld field function okay so done and now yeah guys so it's done now let's go to a controller so from when you click on submit button it will go to the action all imply at store so let's go to the store and let's go with it okay so I have already done with the validation part so I'll just paste it so yeah okay so this is my validation where I'm going to validate it according to it so is now let's code with that the remaining thing so let's create a variable called EMP okay I'll call it employees so it is equal to new that is your model name okay so my model name is nothing but employee okay just be : and this when you're using employee so when you're using this employee model so you have to mention at the top okay so let's use employee I mean use app pack slash I mean forward slash employee okay employee and okay so this means in your mmm let me close in your app folder there is an employee model okay so I'm using that employee model okay ad store so I simple and let's just give the commands to complete the storage to as simple like EMPs of fname okay of your database name is equal to dollar request re qu e SP request that is input off what your name field name okay so f name that is field name and let's copy this ctrl C placed placed okay so f name L name last this address and finally on with mobile okay and let's save it give TPMS that will save the output okay save it and have a direct to written and so return and redirect back to the page okay so that is mmm with the message we will send it okay with one message so the message will be in the success is you see he is a success comma with the data saved okay so data saved and redirect where to the URL main URL okay so main URL is over this one okay resource so let's go back and paste it over here so that will be my resource okay so after saving it will go back and save it okay so now when to show this message I have already done the coding for that so I'm going to paste that code okay let me close this okay so let's go to your model form okay so I'm going to after the container okay inside the container I will paste it taste and let's take this button inside the container itself okay don't let it be out right and now this is our model okay right fine so what I'm going to do is that I take this model full model itself and paste it above the container okay so let it be clear and enough to understand nice okay so now what I'm going to save it let's run it and okay so now what I'm going to do is that launch the model and let's save the data okay so let's enter like first name is with and second name is Prakash so address is Bangalore and mobile number whatever you can give okay some dummy data and let's save it so after saving it should give a message whoops so there is one name that does not default value insert into employee's update okay some name is missing over there so let's check it out with that hmm I think it's a controller mystic let's go to a controller oops we have not changed the validation okay I mean in name and this will be address sorry guys we have done a big mistake so let's see if that and yep let's run it once again so let me go back refresh the page and launch the model and let's save the data with akash addresses bangalore and okay so now let's save this and let's say now both data is saved so let's go to our database you guys there is no inside employee folder i inside table there is no data now let's refresh the data and yeah so you have got the data okay so by using model we are saving the data okay so now let's save one more name called ohm Prakash okay and from Bangalore itself and some data number okay so let's save it and yeah again once again it's got data got saved let's refresh it and check the data okay boom so finally you have learnt how to insert the data using bootstrap model thing okay so in next video we will learn how to retrieve the data on a table okay so guys thank you for watching this video and please subscribe my channel like the video share the video and guys thank you once again
Info
Channel: Funda Of Web IT
Views: 71,051
Rating: undefined out of 5
Keywords: fundaofwebit, how to insert data into database in laravel using modal, how to insert data into database in laravel using pop up modal, how to insert data in laravel using modal, how to insert data using modal in laravel, laravel crud with bootstrap modal, laravel crud with model, laravel crud, bootstrap modal insert data in laravel, insert data using model in laravel, model in laravel
Id: YxTErC4a7sA
Channel Id: undefined
Length: 19min 54sec (1194 seconds)
Published: Sun Nov 04 2018
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.