In this episode, we're kicking things off with some database setup to get our Laravel project ready for future features. We start with a fresh Laravel app, using Laravel Breeze for authentication, and Livewire is already installed. But other than that, everything is at square one.
First, we generate an Article model along with its migration, factory, and seeder using artisan. Our focus is on getting a solid chunk of data to work with (about 100 articles), because this will come in handy later, especially for infinite scroll functionality. We set up the articles table with some basic fields (like title
and body
), and then use the factory to generate realistic data for these columns.
A key part here is making sure the created_at
timestamps for our articles are incremented day by day using the factory's state
and sequence
features, instead of all being created at the exact same moment. This helps us easily verify the order of our data, which is crucial when implementing things like infinite scroll. We seed the database, fix a quick mismatch between the column and what we're generating (switching from body
to teaser
), and make sure everything lines up correctly.
By the end of this episode, we've got a database full of sample articles, properly ordered by their creation date. Everything is set up for smooth sailing in the next step: chunking our data!