What's New In Laravel - The Php Framework For Web Artisans
Published on February 18, 2024 by Dinesh Uprety
![What's New in Laravel - The PHP Framework For Web Artisans](https://laranepal.com/storage/post/thumbnail/01HPYMCFMAQ31EVPGHMPSY7G46.png)
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", "email" => "hari@gmail.com", "role" => "developer" ], [ "name" => "Dinesh Uprety", "email" => "dinesh@gmail.com", "role" => "developer" ], [ "name" => "Manohar Devkota", "email" => "manohar@gmail.com", "role" => "developer" ] ]); $users->select('name', 'email'); // only return selected keys value /* [ [ "name" => "Hari Uprety", "email" => "hari@gmail.com", ], [ "name" => "Dinesh Uprety", "email" => "dinesh@gmail.com", ], [ "name" => "Manohar Devkota", "email" => "manohar@gmail.com", ] ] */