Defining relationships as functions provides powerful method chaining and querying capabilities.Today we are going to discuss how to Count Related Models In Laravel is to get the amount of related records inside of the main object with help of withCount() function. It also works with two layers, inside of hasManyThrough relations.