Sorting Threads By Number Of Replies

Sorting Threads By Number Of Replies

This tutorial will find us tackling a few different topics, however the main goal is to be able to set up sorting threads by popularity according to the number of replies each thread has. To start off, we’ll need to make some changes to the main view which displays all threads. Once we get that sorted to our liking, we can begin fleshing out the test that will be required for our new feature.…

Global Query Scopes And Pagination

Global Query Scopes And Pagination

In this tutorial, we’ll talk about Global Query Scopes and Pagination among other topics. First off, we’ll make some adjustments to the current view file that displays a single thread. Right now the content is centered in a one column style layout. We will modify this to a two column layout with the main content on the left hand side. We’ll then add a smaller right hand column, and then start adding some basic meta type information that might be helpful to the user of the application.…

How To Refactor Code To A Dedicated Class

How To Refactor With PHPStorm

In this tutorial we are going to learn all about how to refactor with PHP Storm. During the course of building our application, we often find the methods in our controllers begin to expand in size. As the need to apply more and more logic happens, we don’t want to see our methods get so convoluted that they become hard to read and reason about. In this tutorial, we’ll try our hand at refactoring some code to make it more pleasant to read and work with in the controller, while still maintaining the same functionality of the application.…

How To Filter Via Query Strings

How To Filter Via Query Strings

This tutorial will focus on adding the ability to filter by query strings when fetching information from the database. There are a few other ways you could do this type of filtering, but many times a simple query string is a nice way to go about it. We’ll start by running all of our tests, and fixing anything that might have gone wrong. Once that is taken care of, we can move on to adding a new feature test to support our new feature of filtering threads by query string.…

How To Use View Composers

How To Use View Composers

In this tutorial we will learn how to use view composers in our little forum application. View composers are a way to make sure certain data is available to view files no matter which endpoint you may be visiting in an application. We’ll discuss placing sql queries in view files, vs having them in a controller, vs making use of view composers. As a little bonus, we’ll also cover how to automatically import a class in PHP Storm.…