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.
Laravel String Pluralization Nov 30, 2016
Learn how to handle pluralization and specific numbers in Laravel's translator. Message tags can be used as comments for different plural translation messages. Laravel allows for handling specific numbers by passing them directly to the translation message. Intervals can also be used in translation messages to match a range of numbers.
Laravel's Bcrypt Hasher Nov 30, 2016
Learn about the Bcrypt hasher in Laravel, how to set the number of rounds for the hash calculation, and how to generate and check hashes using the make and check methods. See examples of generating hashes and checking their validity. Also, discover how to determine if a hash needs to be rehashed and how to use the Hash facade to access hasher methods.
The Laravel Translator Nov 30, 2016
The Translator class is responsible for handling interactions between the application and the translation systems. It implements Symfony's TranslatorInterface and provides functions to determine if a translation exists, retrieve translations with replacements, and pluralize translations. The class also allows you to set and get the current locale and fallback locale. You can access the Translator instance from the application container using the translator name.
An Introduction To Laravel Collections Nov 29, 2016
Learn to use the Illuminate\Support\Collection class in Laravel to manipulate data using familiar array syntax. Access and iterate through the collection using key/value pairs. Retrieve values associated with known keys and work with the underlying array using the toArray method. Be aware that array-specific functions will not work directly on a collection, but can be used on the underlying array. Use methods like get to retrieve data from the collection with the option to return a default value. Create a new collection instance by passing an array of items to the constructor, or by using the make method or the collect helper function.