Laravel maintenance mode and health checks

Maintenance mode gracefully takes applications offline for updates without showing errors. The php artisan down command activates maintenance mode, showing a default or custom view. The --secret option creates bypass tokens for testing. The --retry he

Laravel macro methods for extending framework

Macros dynamically add methods to Laravel's macroable classes—Request, Response, Collection, Query Builder, and more. I define macros in service providers' boot() methods. The macro() method accepts a name and closure. Macros access $this context like

Laravel package development

Creating Laravel packages enables code reusability across projects. I structure packages with src/ for code, config/ for configuration, and database/ for migrations. Service providers register package components—routes, views, commands, configs. The p

Laravel global query scopes with database views

Combining global scopes with database views creates powerful data access patterns for multi-tenancy and security. Global scopes automatically filter all queries for a model—perfect for tenant isolation or active record filtering. I implement the Scope

Laravel route model binding

Route model binding automatically resolves Eloquent models from route parameters, eliminating manual lookups. Implicit binding matches parameter names to model IDs—/users/{user} injects the User model. Custom route keys use getRouteKeyName() to bind b

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 HTTP client for API consumption

Laravel's HTTP client wraps Guzzle with a fluent, expressive API for consuming external APIs. The Http facade provides methods like get(), post(), put(), and delete(). I chain withHeaders(), withToken(), and withBasicAuth() for authentication. The ret

Laravel localization for multi-language apps

Localization enables applications to support multiple languages. Translation strings live in lang/ directories organized by locale. I use the __() helper or @lang directive for translations. The trans_choice() function handles pluralization rules. Lar

Laravel pagination with custom views

Pagination divides large datasets into pages, improving performance and UX. Eloquent's paginate() method returns a paginator with data and metadata. The links() method renders pagination UI. I customize per-page counts with paginate(50). Simple pagina

Laravel model observers for lifecycle hooks

Observers consolidate model event listeners in dedicated classes, preventing bloated models. Each observer method corresponds to an Eloquent event—creating, created, updating, updated, deleting, deleted. I register observers in boot() methods of servi

Laravel custom validation rules

Custom validation rules encapsulate complex validation logic in reusable classes. I create rule classes implementing ValidationRule with a validate() method receiving the attribute, value, and fail closure. Rules access databases, call APIs, or perfor

Laravel custom Artisan commands

Artisan commands automate repetitive tasks via the command line. I create command classes with php artisan make:command defining signatures and descriptions. The handle() method contains command logic. Arguments and options capture user input with typ