In this episode, we're diving into how to set up a transactions model and fill it with a ton of fake data for testing import/export features. We start by creating a simple model called Transaction
with various data types. For example, we talk about the importance of storing monetary values (like dollars and cents) as integers to avoid potential issues, so a dollar is saved as 100
(cents) in the database. We also add fields like transaction IDs, descriptors, and timestamps for when the transactions happen.
Once the model and migration are ready, we jump into the factory to generate realistic fake transaction data. We use unique string IDs, create random monetary values, set random dates within the last 10 years, and add simple descriptors. Then, using Laravel's factory tools, we bulk-generate a huge amount of fake transactions—up to 100,000 records. This helps us have a solid dataset to simulate realistic exporting and importing scenarios later.
By the end of this episode, you'll have a transactions table loaded up with plenty of data, ready for us to test export and import workflows in the next steps.