Reader Stacks

GUIDES

Databases & APIs — Page 2

Database design, queries, and REST/GraphQL API practices.

Bulk Inserting Rows in Laravel Eloquent

A loop of individual ->save() calls means one query per row — insert() (or upsert() for a merge) does it in one, at the cost of skipping model events and timestamps unless handled manually.

How to Fetch Records Between Two Dates in Laravel

whereBetween() handles the basic case cleanly — the real detail to get right is making sure the end date's time component actually includes the whole day, not just midnight.

Useful One-Off Eloquent Query Tricks in Laravel

inRandomOrder() genuinely shuffles at the database level for a small table, but it becomes a real performance concern once a table grows into the millions of rows — worth knowing before reaching for it blindly.

Reading Raw JSON Data From a Laravel Request

$request->json() and $request->input() end up reading the exact same parsed body for a JSON request — the difference only matters once the client sends something Laravel doesn't already parse automatically.

Laravel Migrations: Creating and Running Them

A migration is a version-controlled, reversible description of one schema change — the file, the up()/down() methods, and the commands that actually apply or undo it.

Building a Simple REST API in Laravel 13

A modern Laravel API separates routes, validation, authorization, persistence, resources, authentication and tests instead of returning raw models from controllers.