Using Laravel to build a forum web application with MVC structure, Eloquent ORM, Blade templating engine, and more.
This project was created for the CSC348 Web Application Development module at Swansea University. The aim was to create a forums style website using Laravel as the framework. The project specification allowed me to demonstrate numerous development skills that are key for web development.
The comment system demonstrates creating entries to the database and associating an entry with another model, in this case a comment to a post. Furthermore, by using AJAX, a request is made to update the page in real time to show the new comment, therefore a refresh is not required.
Additionally, posts are associated with users, and these posts can be seen on the profile of that user. This demonstrates the one to many relationship between users and posts. Additionally, only the user who created the comment can see edit and delete buttons.
I decided to use Bootstrap as my CSS framework as I have previously used it in my projects and the extensive documentation meant it was quick for me to setup with my web application.
Using paginate on my Eloquent queries for posts, users, and communities means that the page does not get filled with every single item from the database, and allows me to easily navigate through the pages.
As part of the extra features for the specification I used the service container pattern to implement a weather indicator on a user’s profile. This container makes requests to a weather API and stores the information. This container can be accessed across the entire scope of the website meaning I can easily add the weather feature elsewhere. Furthermore it allows me to easily update the request code if the provider makes breaking changes to their API.
I created two roles, a user and an admin. The admin has the ability to create, edit and delete posts, users, and communities. The user can only create posts and comments. This demonstrates the use of middleware to restrict access to certain pages. Furthermore, the admin can delete users, and this cascades to delete all posts and comments associated with that user.
To achieve this I associated certain permissions to each of these roles, meaning I can easily add new permissions without affecting current roles, and create new roles with certain permissions.