Premium
PHP Snippets.

Curated list of production-ready PHP scripts and coding solutions.

PHP

Laravel Eloquent Mass Assignment Protection (fillable/guarded)

Secure your Laravel application by understanding Eloquent's mass assignment protection. Learn to use `$fillable` or `$guarded` properties to control which model attributes can be mass-assigned.

View Snippet →
PHP

Laravel Eloquent Accessors and Mutators for Data Formatting

Transform model attributes on retrieval and saving using Laravel Eloquent accessors and mutators. Learn to format names, dates, or encrypt data effortlessly.

View Snippet →
PHP

Laravel Eloquent Soft Deletes for Non-Destructive Deletion

Implement non-destructive data deletion in Laravel using Eloquent soft deletes. Learn to retrieve, restore, and permanently delete 'trashed' models.

View Snippet →
PHP

Laravel Eloquent Local Scopes for Reusable Query Logic

Organize and reuse query logic in Laravel with Eloquent local scopes. Create custom methods to easily filter or modify your model queries.

View Snippet →