Because we are queuing our export now, what we can do is add on to the export chain. By that I mean we can just push on any new jobs that we want to follow on from the export process. To do this we use the chain method and we just pass an array of any jobs that we want to push on.
00:20
So let's go ahead and add in a job to mark this export as complete, which we know over in the database is this complete at that column. I'm just going to get rid of what we have in here so far. And just to keep things nice and tidy let's get rid of both of these as well.
00:37
Okay so what do we want to do here? Well we want to create out a new job, so our own custom job now that we can push. And we're going to call this mark export complete. We'll create one for imports as well a little bit later.
00:52
Okay so let's new this up, so new mark export complete. And what do we want to pass into here? Well we want to pass the export itself because that's what we need this to be aware of. And of course we need to actually update this model.
01:05
So over in the constructor for this job let's go ahead and put in that export. And there we go, so under handle all we really need to do here now is say this export and touch completed at. That will push the current timestamp, current date and time to that column.
01:26
And before we forget let's go over to our export model and let's just make sure we have the completed at cast here to a date time. And we should be good. Okay let's go ahead and just export out 10 or so of these records just to check this out.
01:48
And we know that over here completed at should be filled once this export process has finished. So let's go over to the database and yeah sure enough completed at has finished and it has been filled in. Now obviously this was very quick but the longer the process the longer this is going to take.
02:06
And we can actually use this completed at column a little bit later to show a status when we list out all of the exports that we're waiting for. Let's head over to the next episode though and create out another thing that we can push into this chain which is alerting the user by email when the export is complete.
22 episodes•2 hrs 18 mins•1 month ago
Overview
Let's build a powerful CSV importer and exporter with Livewire, completely from scratch.
This can handle millions of rows, be reused for multiple models, and by using queues, doesn't require the browser to be open.
This course is for you if:
You need a robust drop-in importer and exporter component for your models that you have full control over
You want to brush up on some advanced Livewire concepts