In this episode, we focus on creating an "import record" in our application — it's basically a way for us to track imports in much the same way we do for exports. If you've watched the export record video, this is going to feel pretty familiar! We repeat a lot of the same steps, like setting up a new model and creating a migration for imports.
We'll walk through adding fields like the user performing the import, a record count for clarity, and a nullable completed_at
timestamp to know when things finish up. There's also a tip on optionally storing the file name with each import for easier identification in the UI.
Next, we wire up the relationship on the user model so a user can have multiple imports, just like exports. Then we'll test things out by triggering an import, ensuring the record is created with all the right details, and even checking the results in the database.
Towards the end, we make sure to copy over anything useful from the export model (like casts and fillable/guarded properties) to keep everything tidy and working properly. With our import records now in place, we're ready to build out the actual importer and hook up queue processing next!