Urgent.News

What's breaking now, across thousands of outlets.

Tech

Laravel Route Model Binding: Implicit, Explicit & Scoped

Laravel route model binding is the reason a resource controller rarely contains a manual Post::findOrFail($id) call. Part 1 covered how Laravel routing works at a basic level, and ended on the {post} parameter in a resource route resolving straight to a Post model instead of a raw ID. This part covers how that actually happens, and the handful of places it stops working the way you'd expect:…

Laravel route model binding automates the process of retrieving Eloquent models based on URL parameters, eliminating the need for manual lookups. Implicit binding matches the route parameter name to the type-hinted model variable, resolving the model automatically. For custom lookup columns or soft-deleted rows, binding can be scoped to specific columns or enabled with the withTrashed() method.

Scoped bindings allow nested resources to properly associate related records, preventing unauthorized access to other users' data. Explicit binding provides a centralized solution for custom resolution logic applicable across multiple routes. Soft-deleted models are excluded by default but can be included using the withTrashed() method, though care must be taken to ensure compatibility when combining scoped and trashed bindings on parent/child model pairs.

Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.

Read the original at dev.to →

More in Tech

I Built a QR-Code File Transfer App with Spring Boot and Vanilla JavaScript

What if you could send a file from one device to another with no cable, no Bluetooth and no cloud upload, using only a screen and a camera?

  • QR File Transfer app developed using Spring Boot and vanilla JavaScript
  • File broken into 400-byte chunks, encoded in base64 and QR codes
  • Receiver scans QR codes with camera, reconstructs and downloads file

When the cluster looked idle but nothing would schedule

The first thing I checked was the obvious one: CPU. Our non-prod EKS workers are Karpenter-managed, and application pods had been sitting in Pending long enough that Istio and app syncs were backing…

  • Kubernetes cluster pending pods despite ample CPU resources
  • Karpenter logs: "Failed to schedule pod, all available instance types exceed limits for nodepool"
  • Team increased memory limit to 160Gi, removed hardcoded instance type requirement

More from Sunday 4 October →