5 Must Know Methods to Modify Collections - Mastering Eloquent & Collection Methods

In this tutorial, we’re going to cover various methods for modifying collections in Laravel. The first method is the push() method, which adds one or more elements to the end of a collection; put(), which sets a value on a collection by a given key and can update an existing value or append a new key-value pair; forget(), which removes an item from a collection by its key; pop(), which removes the last element from a collection and returns its value; and shift(), which removes the first element from a collection and returns its value. 📚 New Udemy Course If you’re looking to level up your Laravel skills? My new course “Mastering Laravel 10 Query Builder, Eloquent & Relationships“ is the perfect opportunity. Learn the essential tools and techniques for building robust and scalable web applications with Laravel: 📲 Let’s plan a meeting Plan a (paid) 1-hour meeting on Calendly to do portfolio reviews, code reviews resume reviews, or a coaching session for Laravel: 💌 Newsletter Sign up for my free weekly email newsletter: 🔥 Resources - Twitter: - Instagram: - Blog: - Patreon: - GitHub: - TikTok: @codewithdary 📋 Table of Content 00:00 - push() 01:24 - put() 03:43 - forget() 04:41 - pop() 05:51 - shift() 06:35 - Outro #laravel #php #codewithdary
Back to Top