What's New In Laravel - The Php Framework For Web Artisans
Published on February 18, 2024 by Dinesh Uprety
Let's discuss the most recent changes to the framework. I have some really awesome new features. Allow me to demonstrate.
Base64 String Methods
First we have two new methods for a string helper to Str::toBase64() and Str::fromBase64() and you guessed it already, it's about base64 encoding and decoding. We can now do it fluently through the string helper.
<?phpuse Illuminate\Support\Str; $encoded = Str::toBase64('my-string');$decoded = Str::fromBase64($string);
Array Take
Next we got a new method on the array helper. I'll show you.
<?phpuse Illuminate\Support\Arr; $numbers = [1, 2, 3, 4, 5, 6];return Arr::take($numbers, -3);// [4,5,6]
Collection Select
Next we got a new method on Collection select(). I'll show you
<?phpuse Illuminate\Support\Collection; $users = collect([ [ "name" => "Hari Uprety", "role" => "developer" ], [ "name" => "Dinesh Uprety", "role" => "developer" ], [ "name" => "Manohar Devkota", "role" => "developer" ] ]); $users->select('name', 'email'); // only return selected keys value /* [ [ "name" => "Hari Uprety", "email" => "[email protected]", ], [ "name" => "Dinesh Uprety", "email" => "[email protected]", ], [ "name" => "Manohar Devkota", "email" => "[email protected]", ] ] */
Senior Software Engineer • Writer @ Laranepal • PHP, Laravel, Livewire, TailwindCSS & VueJS • CEO @ Laranepal & Founder @ laracodesnap