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
6 views
34
8
2 weeks ago 00:04:23 1
Just apples and cocoa! No sugar! I eat it every day and I’m losing weight before my eyes!
3 weeks ago 00:04:51 1
PUPrime vs IC Markets : Battle of the Best Forex Brokers for 2025!
3 weeks ago 00:03:08 1
Unreal Engine 5 Animation Hack: Attach Actors with Sequencer
4 weeks ago 00:23:07 1
Top 10 Healthiest Vegetables You Must Eat
4 weeks ago 00:05:48 1
Dawid Podsiadło, P.T. Adamczyk — Phantom Liberty (Official Cyberpunk 2077 Music Video)