Sling Academy
Home/PHP/Page 16

PHP

PHP is a popular scripting language for web development. It can create dynamic and interactive web pages by running on the server and sending HTML to the browser. It is free, fast, and flexible,

Eloquent: Defining tables with one-to-one relationships

Updated: Jan 16, 2024
Introduction Defining relationships between tables in a database is a critical aspect of web development when utilizing an Object-Relational Mapping (ORM) tool like Eloquent, which is part of the Laravel framework. A one-to-one......

How to execute subqueries in Eloquent

Updated: Jan 16, 2024
Introduction One of the most powerful features of Laravel’s ORM, Eloquent, is its ability to construct complex queries using an elegant syntax. It helps to keep your database code simple and maintainable. A particularly handy......

How to get the raw SQL query generated by Eloquent

Updated: Jan 16, 2024
Introduction When working with Laravel’s Eloquent ORM, the elegance and simplicity of active record patterns can sometimes obscure the underlying database interactions. For debugging, optimizing, or simply understanding what’s......

Data transactions and commit/rollback in Eloquent

Updated: Jan 16, 2024
Introduction When you’re working with databases, ensuring data integrity and consistency is paramount. One of the ways to secure your data operations in Laravel is by using database transactions. Laravel’s Eloquent ORM......

Eloquent ORM: How to Use Multiple Database Connections

Updated: Jan 16, 2024
Introduction When developing applications with Laravel, using its native ORM, Eloquent, is an elegant approach to interacting with databases. However, as applications grow in complexity, the need to use multiple databases becomes ever......

Eloquent ORM: How to use multiple ‘WHERE’ clauses

Updated: Jan 16, 2024
Introduction Eloquent ORM stands as one of the most prominent features of the Laravel PHP framework, providing a beautiful, simple ActiveRecord implementation for working with your database. When querying a database, the use of......

How to Temporarily Disable Events in Eloquent

Updated: Jan 16, 2024
Introduction When working with Laravel’s Eloquent ORM, developers often encounter scenarios where they wish to temporarily suspend model events. Eloquent events are a set of methods that can be used to hook into various points of......

How to define and use observers in Eloquent

Updated: Jan 16, 2024
Introduction When working with Eloquent in Laravel, you often need to execute certain actions during various stages of the model’s lifecycle, such as creating, updating, or deleting records. The Eloquent Observer class provides a......

How to register and use closures in Eloquent

Updated: Jan 16, 2024
Introduction Eloquent is a powerful ORM (Object-Relational Mapping) tool that comes with Laravel, offering a beautiful, simple ActiveRecord implementation for working with your database. One of the less frequently discussed but......

How to Replicate a Model in Eloquent

Updated: Jan 16, 2024
Introduction When working with Eloquent ORM in the Laravel framework, it’s common to encounter situations where you need to create duplicates or clones of Eloquent model instances. This tutorial explains how to replicate a model......

Pruning Models in Eloquent: Tutorial & Examples

Updated: Jan 16, 2024
Introduction Eloquent ORM is a powerful and advanced database tool native to Laravel, enabling developers to perform complex database operations with minimal effort. In this tutorial, we’ll cover how you can prune or clean up......

Explore soft deletes in Eloquent: A developer’s guide

Updated: Jan 16, 2024
Introduction Soft deletes are a critical feature when it comes to managing deletion of records in web applications. Instead of permanently removing an entry from the database, a soft delete marks a record as ‘deleted’......