In Laravel

Laravel Collection Public API: values

Nov 30, 2016

The values method in Laravel can be used to extract only the values from a collection. It creates a new collection with consecutive numerical keys. Here is an example of how to use the values method in PHP. After executing the code, the resulting collection will contain the values without the original keys.
Laravel Collection Public API: where

Nov 30, 2016

The where method in Laravel allows developers to filter a collection based on a key-value pair. It returns a new collection with items that match the given criteria. The method supports various operators such as equality, inequality, and comparisons. In older versions of Laravel, the filter method can be used for similar functionality.
Laravel Collection Public API: whereIn

Nov 30, 2016

The whereIn method filters a collection based on a specific key and an array of possible values for that key. By default, it checks the types of the values in the collection against the types in the given array. The method returns a new, modified collection without changing the original instance. To use whereIn, you simply call it on a collection and pass the desired key and values as arguments, optionally specifying $strict to control type-checking behavior.
Laravel Collection Public API: whereInLoose

Nov 30, 2016

The whereInLoose method in Laravel's collection allows you to filter the collection based on a given key and an array of possible values, without performing type checking. It is similar to the whereIn method, but does not require a third argument. This method returns a new modified Collection instance, without changing the original instance.
Laravel Collection Public API: whereLoose

Nov 30, 2016

The whereLoose method, similar to the where method, filters a collection by checking if a given key has a value equal to the provided value. The key difference is that whereLoose does not enforce strict data type checks. This method returns a new Collection instance without modifying the original collection. In the example provided, using whereLoose('age', 2) would return a new collection with two items that match the search criteria, including items with different data types for the age key. The whereLoose method can also be achieved using the where method with optional parameters.
Laravel Collection Public API: zip

Nov 30, 2016

The zip method in Laravel's Collection class is used to merge the values of an array with the values in the Collection at the corresponding index. It returns a new Collection instance and does not modify the original collection. Multiple arguments can be passed to zip, and they can be any data type that can be converted to an array. In case of different array lengths, null values are used for missing items, and additional items create new Collection instances.
Laravel Collection Static API: make

Nov 30, 2016

The make static method in the Collection class allows you to create a new instance of a collection with a provided array of items. This method is useful when you want to create a collection without the need for a full constructor call.
Laravel Hashing: One Way Encryption

Nov 30, 2016

This article explains the concept of hashing in software development and distinguishes it from encryption. Hashing is a one-way process where the original message cannot be retrieved from the resulting hash. Laravel provides a Hasher interface that can be implemented to create new hashing providers. The article also mentions the confusion between hashing and encryption and clarifies the storage of salts for password hashes in the database. Additionally, it discusses Laravel's usage of the Hasher implementation and mentions the Bcrypt hasher provided by Laravel, which supports bcrypt password hashing with adjustable work factor.
Laravel: Implementing a CRYPT_EXT_DES Hasher

Nov 30, 2016

This article explains how to create an implementation of Illuminate\Contracts\Hashing\Hasher using PHP's crypt function and the CRYPT_EXT_DES hashing function. The implementation includes the make, check, and needsRehash methods, each with different functionalities. The make method handles the actual hashing, allowing users to supply a salt and control the number of iterations. The check method compares a given value with a hashed value to check if they match. The needsRehash method determines if a hash needs to be rehashed based on the options provided. The code provided includes the complete implementation of the ExtendedDesHasher class.
Laravel: Implementing a CRYPT_SHA256 Hasher

Nov 30, 2016

Learn how to create an implementation of Illuminate\Contracts\Hashing\Hasher using PHP's crypt function and the CRYPT_SHA256 hashing function. Explore each method before examining the full implementation. The make method accepts an $options array, which can include a salt and the number of hashing iterations. The check method compares a known value with a hashed value, using PHP's crypt function. The needsRehash method determines if a hash needs to be rehashed, based on the salt and number of iterations.
Laravel: Implementing a CRYPT_SHA512 Hasher

Nov 30, 2016

This article explains how to create an implementation of Illuminate\Contracts\Hashing\Hasher using PHP's crypt function and the CRYPT_SHA512 hashing function. The article provides the step-by-step process for implementing each method of the contract. Additionally, it introduces the Sha512Hasher class, which extends the Sha256Hasher class and makes a simple change to match the SHA-512 hashing function.
Laravel: Implementing a CRYPT_STD_DES Hasher

Nov 30, 2016

Learn how to create a custom implementation of the Illuminate\Contracts\Hashing\Hasher contract in PHP. This implementation uses PHP's crypt function and the CRYPT_STD_DES hashing algorithm. The implementation includes methods for hashing, checking hashed values, and determining if a hash needs to be rehashed. The implementation also allows for the option of supplying a custom salt. See a complete example of the implementation and usage in the article.
Laravel: Implementing a MD5 Hasher

Nov 30, 2016

This article explains how to create an implementation of Illuminate\Contracts\Hashing\Hasher in PHP using the crypt function and the CRYPT_MD5 hashing function. The article breaks down each method and provides a complete implementation of the Md5Hasher class at the end. By following this guide, you can create your own custom hashing implementation in Laravel.
Laravel Localization: The File Loader

Nov 30, 2016

The FileLoader class in Laravel is responsible for loading translation files from the file system. By default, the language files are loaded from the /resources/lang/ directory, with each sub-directory within lang/ corresponding to a specific locale. Each locale directory contains PHP files that return key/value pairs for translations. These files are referred to as "groups". The FileLoader implements the LoaderInterface contract, which includes the load and addNamespace methods for loading translations and adding namespaces, respectively. Translation namespaces are used to prevent conflicts between multiple vendors using the same group names for a locale. The * namespace refers to groups in the default /resources/lang directory, and custom namespaces can be added using the addNamespace method.

Some absolutely amazing
people

The following amazing people help support this site and my open source projects ♥️
If you're interesting in supporting my work and want to show up on this list, check out my GitHub Sponsors Profile.