Laravel – My Journey – Part 1 – Shopping List Application

LARAVEL Multi-user shopping list application

At the start of July 2017, I started a 12-month work placement as a web developer. The placement is with Two Superior Studios Ltd, a small studio based at Plymouth Science Park. Two Superior primarily work with the Laravel PHP framework. Prior to this placement, my PHP skills were a little rusty, and I’d not even heard of Laravel nor used an MVC framework.

It’s now October. Having worked on a number of client projects and got my feet wet, I decided it was time for me to create my own application.

Important Note/Disclaimer
This is not a tutorial, nor an example of best practice. The techniques described in this article are not to be taken as efficient or secure. At the time of writing, I am a relative newcomer to Laravel, object-oriented programming, and the MVC paradigm. I won't be explaining every detail. I don't know all the theory. I'll probably get stuff to work and not know how I did it. I'll probably write things that are clearly untrue or, at best, inaccurate. This is me just finding my way ...
Motivation

I wanted to create an application from scratch for a number of reasons:

  • First of all, I had only been working on discrete  portions of functionality within larger projects, never creating a new Laravel application from scratch.
  • Secondly, for a beginner to the framework and MVC, the client projects were complex systems; for my own application, I wanted to start simple and build the complexity as I went along
  • Finally, there is a requirement to complete work for paying clients on time and to a good standard. Creating my own project would allow me to spend time learning and developing without a time (or quality!) constraint.
But what to build?

I had followed along with Jeffrey Way’s excellent Laracasts series and developed a blog application. Jason Gilmore’s Easy Laravel 5 also provided the foundations for me to create a todo list application. And, whilst initially a little intimidating to the Laravel beginner, Matt Stauffer’s book, Laravel Up & Running, is now proving less and less scary and more and more understandable.

Having covered the Laravel equivalents of ‘Hello World‘, it was time for something different. Something of my own.

Therefore, with simplicity in mind, I decided upon a shopping/grocery list application. My thinking was that this would allow me to develop an application from start to finish and provide an exercise in applying what I had learned working on client projects to my own work.

Application requirements

Shopping list image

A shopping list is just a list of shopping right? Sure, but even a simple application can quickly get out of hand and having the basics of a plan before beginning to code is essential. It’s very tempting to add features and enhancements before the core functionality has been developed, tested and refined.

As a minimum, my shopping list application will have the following functionality:

  • User registration, login and password reset capabilities
  • A user can create, view, update and delete multiple shopping lists
  • Users can create, view, update and delete multiple products
  • A user can add products to a shopping list they have created
  • Users can remove products from a shopping list they have created
  • Products can be marked as ‘essential’ i.e. to indicate a product that will always be included on a list
  • Shopping lists can be sent via email to the user
Some rules

Along with the above list of basic requirements, the application will initially operate within a few simple rules:

  • A user may not add a product with the same name more than once; the name must be unique … however …
  • A user may add a product with the same name as that added by a different user
  • Both shopping lists and products will be ‘private’ to a user i.e. they will not be visible to other users
  • If a user deletes a shopping list, any products that have been associated with that list will no longer be associated. However, the products will not be permanently removed from the database
  • If a user deletes a product, it will be permanently removed, including from any lists to which it was associated

With my application requirements and rules established, I think I’ve got a good foundation. Part 2 of this series will see me building on this foundation as I start looking at the first element of the Model-View-Controller pattern: The Model.

Leave a Reply