Code Explainers

Code explainers tagged #eager-loading

php
<?php
 
namespace App\Services;
 

Building a cached daily leaderboard in Laravel

caching aggregation eager-loading
Intermediate 9 steps
ruby
class ProjectsController < ApplicationController
  def new
    @project = current_account.projects.build
    load_form_collections

The new/create pattern in a Rails controller

mvc strong-parameters tenant-scoping
Intermediate 7 steps
php
<?php
 
namespace App\Http\Controllers\Api;
 

Building a cursor-paginated feed in Laravel

cursor-pagination eager-loading validation
Intermediate 8 steps
php
<?php
 
namespace App\Models;
 

Making an Eloquent model searchable with Scout in Laravel

full-text-search indexing eloquent
Intermediate 8 steps
ruby
class Api::V1::ArticlesController < Api::V1::BaseController
  def index
    articles = Article
      .published

Building a JSON:API endpoint in Rails

serialization eager-loading pagination
Intermediate 7 steps
php
class PostController extends Controller
{
    public function index(Request $request)
    {

Eager loading without N+1 in Laravel

eager-loading n+1 query-builder
Intermediate 9 steps
php
class PostController extends Controller
{
    public function index(Request $request): AnonymousResourceCollection
    {

Filtered, paginated JSON APIs in Laravel

eloquent query-builder api-resources
Intermediate 8 steps