Laravel 9 Livewire Bootstrap Modal CRUD 4: How to Confirm and Delete data w/ Modal POPUP in Livewire

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hey guys welcome back so guys we are continuing our laravel live workload application with bootstrap model so guys as we have seen that how to add and how to edit and now guys we are going to see how to delete the data using livewire okay so guys now let's get started so let's move to this table view at the livewire plate file so here is our livewire show student and here is my delete button so now guys once i click this button i need a pop-up model so let us copy the code for popping the model and here let's tell delete student model okay so you need to create one model so we have extended the file i mean included the file and in that we are keeping the model okay so as we have kept the let's copy and here i paste the model let's copy this student id i mean model id here i replace done and let's tell delete student and we have to submit the data okay so what submit data you are going to do you will tell delete student okay so yep and we don't require any of this input records let's remove that instead we will add h4 tags are you sure you want to delete this data question mark okay and tell your yes delete okay all done so once you submit you are going to student delete and delete the record so before that we need to pop up the model right so what what model this delete model so let's get back to our blade livewire blade add this delete model okay so with this when you click on this delete we have to take the id also okay so like when you click on this delete button a pop-up model should be sent with the id so guys for that we have to check out with our wire okay live wire thing so before that let's create this input type of button paste here and instead of a tag let's use a button perfect yep and now you can create a wire colon click is equal to delete student where curly bracket and here you are going to send your student id data so let's send that all done and now you let's copy this and go to our model component let us create a function with named delete student where we are getting the integer type id and that is nothing but your student id okay so student id perfect so now guys you are going to send this id dollar this of student id is equal to your student id you will send in that and then you are going to destroy the data okay so before the let's get back to our model so once you click on this yes delete you are going to delete student so we have already created a delete student function instead we will tell destroy destroy student so let's copy this function name and get back so yep and now you can create another function function with destroy student let's remove this and here our code comes for deleting the record so let's create one variable called student is equal to where our model student colon colon find function your finding and then you are going to delete that record as simple so what data you are going to find dollar this of student id so this student underscore id is coming from your the variable we have already declared okay so when you select that student delete it sends to that and from this student id we are calling that student id and then deleting it so once deleted we have to what to do uh we need to send the message and the dispatch code too let's copy this and paste here we don't have any input let's remove that instead and here is a closed model okay student deleted successfully perfect so now guys uh when you close this model it goes goes to your index blade okay so here you copy and paste and get back to your model copy your model id and paste that that's it so once you done with that you're going to close that model yep so now guys let's uh test it let's refresh and now let's delete the fourth record alexa yes sure delete and let's see what happens student deleted successfully and that data has gone guys perfect so so guys we have done with our confirm and delete option in laravel live wire using bootstrap model okay so guys in this video that's it and let's continue next video with the search option okay so thank you for watching this video guys please subscribe like and share
Info
Channel: Funda Of Web IT
Views: 4,179
Rating: undefined out of 5
Keywords: fundaofwebit, livewire confirm delete data in laravel, laravel 9 livewire delete data using modal, delete data using modal in livewire, confirm and delete data in livewire, how to confirm and delete data in laravel livewire, livewire modal delete data, laravel livewire crud tutorial, how to confirm and delete data from database in livewire, livewire tutorial, laravel livewire tutorial, crud in livewire, laravel 9 livewire tutorial
Id: sg1EnDxoOxo
Channel Id: undefined
Length: 6min 29sec (389 seconds)
Published: Sun Apr 03 2022
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.