Training employees on a new product can be hard, especially if you never directly work with them. Larger companies use tools like Litmos  or software provided by the product vendor, but these can be prohibitively expensive, especially for small businesses that need to train potentially hundreds of purchaser employees on their new product. That is why I have taken the next few weeks to build out a simple LMS with essential features for small business vendors.

Users will be broken up into three categories: administrators (those that have full access to modules, quizzes, and users), verified users (those that are granted access to the modules & quizzes), and unverified users (users awaiting verification from an administrator). Modules will be essentially a title and an HTML body (for embedding videos, PDFs, and other content), and quizzes will be multiple choice. Users will select a module, learn from them, and then will take a quiz to prove their profiency of the material.

I have decided to go with the Laravel Framework as the foundation, with a MySQL database being the backend. Laravel also supports other databases including PostgreSQL and SQLite, however as MySQL and PHP is a fairly common (and cheap!) stack, that is what I am developing against.

Here’s the schema I quickly created that will provide everything I will need:

Getting started with Laravel was painfully easy with the Composer dependency manager. Just fire up a terminal and run:
composer create-project laravel/laravel ModuleBasedTraining
and creating the structure was even easier thanks to the very helpful and readable documentation on Laravel’s data model (dubbed Eloquent). Laravel also includes a full user model out of the box, complete with registration, validation, and reset password functionality. Extending the user model to track admin and verification status was also a breeze, just edit the database migration in the /database/migrations/ folder for users and add in the variables you need, Eloquent takes care of the rest.

Now how do I actually prevent regular users from accessing the admin pages? Laravel also supports middleware, which sits between the request and the controller for the page you will need. Laravel’s CLI (artisan) makes it simple to create a new middleware object (as well as many other objects used in Laravel).

php artisan make:middleware Admin

This creates the file app/Http/Middleware/Admin.php which I modified to check if a user’s admin flag was set to true.

namespace ModuleBasedTraining\Http\Middleware;
use Closure;
use Illuminate\Support\Facades\Auth;
class Admin
* Handle an incoming request.
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
public function handle($request, Closure $next)
if ( Auth::check() && Auth::user()->admin === 1 )
return $next($request);
return redirect('/?notadmin');

Which could then be added into the constructor of our admin controllers:

public function __construct()

So far, Laravel has taken a lot of the grunt-work and repetitiveness out of making web apps, so far I can say that I am certainly a fan of it..

Making a CRUD resource was also easy with artisan. Full source code available here.

This blog post is the first of a series on the development of this app, up next I discuss MaterializeCSS which is simple like bootstrap, but brings the design into 2018.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.


1 2 3 4
February 28th, 2018

Concluding the February Challenge

Writing every day for the month of February has been an experience, and has changed my perspective on writing tremendously. […]

February 27th, 2018


Cloudflare stats are very useful, but they expire and can’t be tracked over a long period of time. That’s why […]

February 26th, 2018

Nightly Database Backups to Google Drive

If you have a Google Apps account (a business account with more than 5 users or one provided by your […]

February 25th, 2018

Sublime Text

Sublime Text is a really powerful text editor and includes tons of functionality relevant to programming. I will dive into […]

February 24th, 2018

Great Resources for Student Developers

Being enrolled in a university comes with its pros and cons (a topic itself worthy of many other blog posts), […]

February 23rd, 2018

What is MVC?

MVC is a term thrown around lots of software development projects. Laravel, Zend, CodeIgniter, Ruby on Rails, Django, iOS, and […]

February 22nd, 2018

Getting Started With Phalcon PHP

To get started with Phalcon, I already have my server stack setup with Ubuntu 16.04, Percona MySQL, Nginx, and PHP […]

February 21st, 2018

What is Phalcon?

Phalcon is a modern PHP framework with the typical feature set you’d expect. Database ORM, error handling, MVC architecture, and […]

February 20th, 2018

Setting Up a PHP Development Environment

If you do PHP development, moving to a PHP IDE is extremely beneficial especially when debugging. PHPStorm is a great […]