The database query builder in Laravel provides a simple, intuitive interface for generating and performing database queries. It works with every one of Laravel's supported database systems and may be used to conduct most operations on the database in your application.
In this example, I'll teach you how to use the first() and firstWhere() methods to construct the Laravel 8 Collection. When working on a Laravel project, we should make use of Laravel collection to make processing array data easier. To generate a new collection instance from our array, we'll utilise Laravel's collect helper function.
And there are occasions when you need to get the first element or use a condition query to display the first Laravel collection result. It will be easier for us if we use the first() and firstWhere() methods.