Weighted random selection in Eloquent: A Practical Guide
Updated: Jan 16, 2024
Introduction When dealing with random selections in database queries, especially when using the Eloquent ORM (Object-Relational Mapping) in Laravel, there might be situations where you want certain records to be more likely to be......
Eloquent: 5 ways to select N random records
Updated: Jan 16, 2024
Introduction Engaging with databases in such a way that you require randomness in results returned is a fairly common scenario in web development. When using Laravel’s Eloquent, several methods can be employed to retrieve a......
Eloquent: 4 ways to select a random record.
Updated: Jan 16, 2024
Introduction When working with databases, you may occasionally need to retrieve a random record. With Laravel’s Eloquent ORM, several methods are available to achieve this. This article explores different solutions to select a......
Eloquent: Find records in last day/week/month/year
Updated: Jan 16, 2024
Introduction In the world of web development, working with dates and times is an everyday necessity. If you’re using Laravel, Eloquent makes this task especially streamlined. In this tutorial, we’ll be diving into how to......
Eloquent: Find Records Between Two Dates
Updated: Jan 16, 2024
Introduction When working with applications that have time-sensitive data, it is often necessary to retrieve records that fall between two specific dates. In Laravel’s Eloquent, this is a common task for developers. Eloquent......
Eloquent: Find records where column is null/not null
Updated: Jan 16, 2024
Introduction Working with databases means you’ll eventually need to query for records where a particular column is null or not null. In Laravel’s Eloquent ORM, this is a straightforward process, offering clear and......
Working with JSON columns in Eloquent: A Practical Guide
Updated: Jan 16, 2024
Introduction JSON data types are a flexible means of storing structured data. When working with databases in Laravel applications, Eloquent ORM (Object-Relational Mapper) provides an elegant way to interact with JSON columns. In this......
Eloquent: How to Check if a Model Attribute Changed
Updated: Jan 16, 2024
Introduction Eloquent, the ORM (Object Relational Mapper) used in Laravel, makes it incredibly easy to interact with a database using an expressive syntax. Among its many features is the ability to detect if a model’s attribute has......
How to insert/update/delete a record with Eloquent
Updated: Jan 16, 2024
Overview Eloquent is an object-relational mapper (ORM) included with Laravel, which makes it easy for developers to interact with database operations using expressive, object-oriented syntax. In this tutorial, we will focus on the......
Eloquent Aggregates: Count, Sum, Max, Min, Average
Updated: Jan 16, 2024
Understanding Eloquent Aggregates Laravel’s Eloquent ORM offers developers a beautifully simple ActiveRecord implementation for working with databases. In this guide, we’ll dive into one of its less-celebrated, yet highly......
Eloquent Upsert: Update if exists, Insert if not
Updated: Jan 16, 2024
Introduction Managing database records involves several operations, of which Insert and Update are the most common. But what if we have a situation where we need to either insert a new record or update an existing one based on some......
Using where() method in Eloquent to filter query results
Updated: Jan 16, 2024
Introduction When dealing with databases in Laravel, the Eloquent ORM is a powerful tool that conveniently allows you to interact with your database using expressive, fluent syntax. One of the most commonly used methods in Eloquent is......