Join 25,000+ Laravel Developers and join the free Laravel Newsletter

Eloquent

Laravel Relationship Events
Laravel Packages / July 09, 2018

Laravel Relationship Events

Laravel Relationship Events is a package by Viacheslav Ostrovskiy that adds extra relationship events to models. Learn how it can help you gain access to relationship events within your associated models.

Read more…
Laravel Eloquent Status Package
News / June 18, 2018

Laravel Eloquent Status Package

The Laravel Eloquent Status package by Rasmus Christoffer Nielsen is a package that helps you check the state and status of eloquent models without cluttering them. Learn more details about this package and how to use it in your own Laravel projects to define and check model statuses.

Read more…
Cascading Soft Deletes with Laravel 5
Laravel Packages / April 24, 2018

Cascading Soft Deletes with Laravel 5

Laravel Soft Cascade is a package that makes it easy to perform soft cascade deletes and restores on related models using soft deleting. Learn more about the inspiration for making the laravel-soft-delete package and how to get started.

Read more…
Leverage Eloquent To Prepare Your URLs
Laravel Tutorials / April 16, 2018

Leverage Eloquent To Prepare Your URLs

It’s not uncommon to have tens, if not hundreds of views in a Laravel application. Something that soon gets out of hand is the various references to routes. If for whatever reason we have to make a change to either the route alias or default query string values you’ll soon find yourself doing mass string replacements across your entire application which brings the risk of breakage within many files.

What can we do to possibly better handle this? There are a couple of differ... Read more…

20 Laravel Eloquent Tips and Tricks
Laravel Tutorials / April 13, 2018

20 Laravel Eloquent Tips and Tricks

Eloquent ORM seems like a simple mechanism, but under the hood, there’s a lot of semi-hidden functions and less-known ways to achieve more with it. In this article, I will show you a few tricks.

Read more…
Getting Started with Laravel Model Events
Laravel Tutorials / March 15, 2018

Getting Started with Laravel Model Events

Laravel Model events allow you to tap into various points in a model’s lifecycle, and can even prevent a save or delete from happening. The Laravel model events documentation outlines how you can hook into these events with event classes, and this article aims to build upon and fill in a few additional details on setting up events and listeners.

Read more…
Laravel Shareable Models Package
Laravel Packages / September 04, 2017

Laravel Shareable Models Package

The Laravel Shareable Models package allows you to generate shareable links from your Eloquent models. Think dynamic routes which only exist for models that have been shared. The package author Kai Sassnowski described his use-case for the Shareable Models package as follows: My initial use case was giving certain non-admin user access to a certain …

Optimize Laravel Eloquent Queries with Eager Loading
Laravel Tutorials / August 07, 2017

Optimize Laravel Eloquent Queries with Eager Loading

Learn how to optimize your related model queries in Laravel with eager loading. We will set up some example relationships and then walk through how queries change with and without eager loading. I like to get my hands directly on code and experiment with things, and I hope to illustrate how eager loading works with some examples will further help you understand how to optimize your queries.

Read more…
Laravel 5.5 Pivot Casting
Laravel 5.5 / July 05, 2017

Laravel 5.5 Pivot Casting

A new addition to Laravel 5.5 will add support for pivot table casts when inserting & updating data on an intermediate table model.

Read more…
Laravel Eloquent Relationships Through Macros
Laravel 5.4 / February 02, 2017

Laravel Eloquent Relationships Through Macros

A new feature just merged into Laravel and included in the v5.4.8 update is the ability to define Macros for Eloquent Relationships. To better show how this feature works here is a screenshot by Jordan Pittman who created the original pull request: Here is that same example in a copy and paste friendly version. AppServiceProvider …