laravel

Laravel service container and dependency injection

Laravel's service container manages class dependencies and performs dependency injection automatically. When type-hinting interfaces or classes in constructors, Laravel resolves them from the container. I bind interfaces to implementations in service

Laravel mix/Vite for asset compilation

Laravel Vite (replacing Mix) compiles and bundles frontend assets with hot module replacement during development. I define entry points in vite.config.js—typically resources/js/app.js and resources/css/app.css. The @vite directive includes compiled as

Laravel database migrations for schema management

Migrations version control database schema changes, making them trackable and reversible. Each migration file contains up() and down() methods defining changes and rollbacks. I use the Schema builder's fluent API to create tables, add columns, define

Laravel form requests for validation

Form requests encapsulate validation logic in dedicated classes, keeping controllers thin and focused. Each form request extends FormRequest and defines rules() and optionally authorize() methods. The authorize() method checks if the user can perform

Laravel soft deletes for data retention

Soft deletes mark records as deleted without removing them from the database, enabling recovery and audit trails. I add SoftDeletes trait to models and a deleted_at timestamp column. Calling delete() sets deleted_at instead of removing rows. Soft-dele

Laravel notifications for multi-channel messaging

Laravel notifications send messages across email, SMS, Slack, database, and more via a unified API. I create notification classes extending Notification with channel-specific methods—toMail(), toDatabase(), toSlack(). The via() method determines which

Laravel Blade components for reusable UI

Blade components create reusable, self-contained UI elements with their own logic and styling. Anonymous components are simple Blade files, while class-based components have PHP backing classes. I pass data via attributes—<x-alert type='success' /&

Laravel Eloquent relationships with eager loading

Eloquent ORM makes working with database relationships intuitive and powerful. I define relationships using methods like belongsTo, hasMany, and belongsToMany that return query builders. The beauty of Eloquent is lazy loading—relationships load only w

Laravel scopes for reusable query logic

Query scopes encapsulate common query constraints into reusable methods on models. Local scopes prefix methods with scope and accept a query builder plus additional parameters. I chain scopes fluently—Post::published()->featured()->get(). Global

Laravel rate limiting for API protection

Rate limiting prevents API abuse by restricting request frequency per user or IP. Laravel's RateLimiter facade defines limits in RouteServiceProvider. I apply limiters via middleware—throttle:api for the default API limiter. Custom limiters use closur

Laravel broadcasting with Pusher for real-time events

Broadcasting enables real-time features by pushing server events to connected clients via WebSockets. I implement ShouldBroadcast on events to automatically broadcast them when fired. The broadcastOn() method defines channels—public, private, or prese

Laravel collections for data manipulation

Laravel collections provide a fluent, powerful API for working with arrays. Every Eloquent query returns a collection, but I also create collections from arrays with collect(). Methods like map(), filter(), reduce(), groupBy(), and sortBy() transform