Search

Showing 7 of 1,216 result(s)

/blog/2018/04/22/laravel-5-collections-conditionally-removing-elements-from-a-collection-with-reject#content-signature

The following code example demonstrates the usage of the reject method by rejecting any name that does not begin with the letter a (ignoring case): After the above code executes, the $names variable will be an instance of Collection and contain a...

/blog/2018/04/22/laravel-5-collections-conditionally-removing-elements-from-a-collection-with-reject#content-using-reject-with-higher-order-messages

The reject method can also be used with higher order messaging, which allows us to invoke collection methods and access properties on objects using PHP's property accessors syntax. In the following example, we will create a simple Product class...

/blog/2018/04/22/laravel-5-collections-converting-a-collections-contents-to-json-with-tojson#content-signature

The following code examples demonstrate the basic use of the toJson method: After the above code executes, $jsonValue would contain the following value: [{"name":"Shirley","age":60},{"name":"John","age":55}] Alternatively, a well-formatted value...

/blog/2018/04/22/laravel-5-collections-converting-a-collections-contents-to-json-with-tojson#content-tojson-and-deeply-nested-data-structures

The toJson method internally makes a call to PHP's json_encode function. Unlike PHP's json_encode function, the toJson method does not provide a way to specify the depth (essentially how many arrays are nested inside of each other) to which data...

/blog/2018/04/22/laravel-5-collections-determining-if-a-collection-contains-an-element-with-contains#content-signature

The following demonstrates the contains method in its most basic usage: The following demonstrates using the contains method to check if a given key/value pair exists in a collection that contains arrays as items: The following example shows how...

/blog/2018/04/22/laravel-5-collections-determining-if-a-collection-contains-an-element-with-contains#content-considerations-of-the-contains-method

The contains method defines two parameters: $key and $value . The $value parameter has a default value of null , however, the two method calls are not the same: Even though the two examples return true , the second example is functionally not...

/blog/2018/04/22/laravel-5-collections-determining-if-a-collection-contains-an-element-with-contains#content-using-contains-with-higher-order-messages

The contains method can also be used with higher order messaging, which allows us to invoke collection methods and access properties on objects using PHP's property accessors syntax. In the following example, we will modify the User class we...

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.