Skip to content
Luca Ubiali Web Developer

Real Time Games With Laravel - Basic Matchmaking

August 26th, 2024
Continuous Learning

Episode - https://laracasts.com/series/real-time-games-with-laravel/episodes/1


This will be tic-tac-toe with Laravel, Inertia.js and Vue.js. It’s been a few months since I touched brutalbudget.com code (my Vue.js project) so this will be a nice refresher.

This first episode is about creating the Game model which will allow matching up two players. It feels like a kata to scaffold all is needed around the model. Even if this is something a Laravel dev does pretty often is impossible to get to the end without even a tiny mistake.

  1. use artisan to create model, factory, migration, policy and resource

  2. define the migration to connect foreign ids for player one and player two

  3. add relationship to the game model to connect it to users

  4. run the seeded to get the test user ready in Laravel Breeze

  5. create a first Inertia Link in the UI to allow the creation of a game through POST request

  6. implement store and show method in the Game controller

  7. add routes in web.php through Route::resource()->only(['store', 'show'])

  8. go back to the Game model to add the $fillable property as the app throws an error as soon as we try to save a Game 😅