Building a Scheduling App in Laravel - Part Two

Part 2 in a series of building a scheduling application using Laravel.

It's been a while since I updated this series, and I've been working diligently, if not quickly, on building my app.

I'll have to go back a month to describe what I've been doing, so bare with me if some of the details are a bit sketchy!

So the first stage, was to complete the CRUD functionality. I managed to complete this inside Blade templates and it was fairly straightforward! Thanks Laravel!

At this point I took a bit of time to think about the next stages. I decided there were two main things I wanted to focus on:

  1. Building the Application in Vue.js instead of in Blade templates
  2. Mastering the relationships between instances and sessions to reduce the number of queries being run.

The first point here then brought up other issues:

  1. I don't know any Vue other than the basics
  2. Do I go the API route or the Inertia route?

I decided to go the Inertia route (after building part of the API anyway!) - it seemed simpler and therefore quicker to get back to where I needed to be. This is still a work in progress but I don't think I'm far off.

For those who don't know, Inertia is essentially a plugin for both Laravel and a number of front end frameworks to connect the two - it means the syntax for passing data from the backend to frontend is not much different. All that's needed it to use Inertia\Inertia in the Controller, then return Inertia::render($page, $data) - where $page is the vue Page component being returned and the data being whatever you want to pass to the template.

I must admit I needed help solving the query problem - but it is solved and I'm really happy about it. Previously I was loading all sessions and doing the mapping on the front end. Fine for a small app, where I know I'm assigning the sessions myself. However, if i have 500 or 5000 sessions, and only say, 100 of them are mapped to an instance, I'll have wasted resources fetching the rest.

What I had missed was the eager loading of the instance_session relationship to the instance. Once that was done, I could see all the sessions that belonged to that instance. Boom!

With that done, I need to re-do the CRUD functionality in Vue - hopefully not that hard given that it's essentially the same Controllers and HTML.

One other thing I have implemented since last month is user roles - using a package by Spatie - User Roles. The main reason I want to implement this is to show/hide things on the front end, particularly an admin nav bar. However, I think it may also be really useful in protecting my routes by role. That should be an interesting feature!

I hope to have more updates on this app in the near future, I'm sure happy how it's coming along!

Get in touch!

Let's work together

We’d love to hear from you! Send us a message using the form opposite, or email us. We’d love to hear from you! Send us a message using the form opposite, or email us.

Optional
Max. 500 characters